Wednesday, November 11, 2009 11:47 AM Yonggang Meng

Get the last day of the month use javascript in VS2008

I have a function which returns the last day of a month. The function is like this:

In Javascript Editor, it works like the above picture.

But in VS2008, it's strange.

I am very strange for this, then I Bing,

http://www.w3schools.com/jsref/jsref_parseInt.asp

See the fuction parseInt(string, radix)

String: the value you want to convert to number.

Rules:

If the string begins with "0x", the radix is 16 (hexadecimal)

If the string begins with "0", the radix is 8 (octal). This feature is deprecated

If the string begins with any other value, the radix is 10 (decimal)

Then, I change my codes

var month = parseInt(strs[1]);

to

var month = parseInt(strs[1],10);

It functions.

Javascript Editor seems not function well.

====================================================================

The JS codes have something wrong. I change it to this:

var strs = p_InputMonth.split("/");
var year = parseInt(strs[0]);
var month = parseInt(strs[1], 10);
var date = new Date(year,month, 0 ); 0: the last day of the month. (Month Index: 0...11)
var lastDay = date.getDate();

When i use new Date(2009,9,iDay) or Date.setDate(iDay) in Javascript Editor, if iDay is not in (1...31) , it will pop an error message "It's a not valid parameter."

but in IE, the js codes work well.

====================================================================

date.setFullYear(year, month+1,1);
date = new Date(date/86400000);
var lastDay =date.getDate();

In Javascript Editor, i must use "/", but in IE i should use "-"

====================================================================

Why Javascript Editor is different with IE? is it just because my JS Editor is free version???

Filed under: , , ,

Comments

# re: Get the last day of the month use javascript in VS2008

Saturday, February 19, 2011 3:40 AM by Whitny Kripke

It was rather interesting for me to read this blog. Thanx for it. I like such topics and everything connected to them. I would like to read a bit more on that site soon.    

Whitny  Kripke  

<a href="indianescortmodels.com/">Indian escorts services</a>

# re: Get the last day of the month use javascript in VS2008

Monday, February 28, 2011 9:50 PM by Jenny Flouee

It was certainly interesting for me to read that post. Thanks for it. I like such themes and everything that is connected to this matter. I would like to read a bit more on that site soon.    

Jenny  Flouee    

<a href="www.latinescortlondon.com/">London escorts latin</a>

# re: Get the last day of the month use javascript in VS2008

Saturday, March 05, 2011 12:08 PM by Natasha Trider

It is certainly interesting for me to read that blog. Thank author for it. I like such topics and anything connected to this matter. I would like to read a bit more soon.      

Natasha  Trider    

<a href="www.jammer-store.com/">cell phone signal scrambler</a>

# re: Get the last day of the month use javascript in VS2008

Friday, March 18, 2011 2:54 PM by Whitny Stepman

It is extremely interesting for me to read this article. Thanks for it. I like such topics and anything connected to this matter. I definitely want to read more soon.        

Whitny  Stepman      

<a href="rome-escort.info/">escorts in roma</a>

# re: Get the last day of the month use javascript in VS2008

Tuesday, April 12, 2011 4:51 AM by Jane Swingfield

It was rather interesting for me to read the post. Thanx for it. I like such themes and everything that is connected to this matter. I definitely want to read a bit more on this blog soon.          

Jane  Swingfield          

<a href="milanescorts.com/">escort in milan</a>

Leave a Comment

(required) 
(required) 
(optional)
(required)