views:

37

answers:

3

Hello.

var date = new Date();//Mon Mar 15 2010 12:40:05 GMT+0300 (MSK) 
var omg = date.getDate() + 19;// 34 
date.setDate(omg);
document.write(date.toLocaleString()); //Sat 03 Apr 2010 12:43:00 PM MSK 

How do I echo the values 3 (ie: day of month), 4 (April) and the current year?

alert(day); // Need 3
alert(month); // Need 4

Thank you

A: 

Please refer to W3 Schools documentation on this.

XpiritO
Why the down vote?
XpiritO
Sorry, I have to -1 this, I almost choked when I saw it. W3Schools are not related to W3C in any way, the pages on their site are not "W3C documentation". Furthermore, W3C do not have any involvement with the ECMAScript (JavaScript) specification. For that, you should be looking at http://ecmascript.org.
Andy E
Ok then, -1 for a typo. That's fair :)
XpiritO
@XPiritO: Even typos can be misleading or misinforming, it makes sense to -1 when you think about the dangers of people thinking W3 Schools are w3c ;-) Now you've fixed your answer I've removed it.
Andy E
As I said, I understood your motives and accepted you decision.
XpiritO
+2  A: 

Year: date.getFullYear(). Month: date.getMonth(). Date: date.getDate().

Take a look at the reference at MDC.

tdolsen
note that getMonth is 0 indexed: it returns "3" for April.
nickf
+1  A: 
date.getDate();

date.getMonth() + 1

date.getFullYear()

If you want to get the date according to universal time then

date.getUTCDate();

date.getUTCMonth() + 1

date.getUTCFullYear()
rahul