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 MS开发者_开发技巧K
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
Year: date.getFullYear()
. Month: date.getMonth()
. Date: date.getDate()
.
Take a look at the reference at MDC.
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()
精彩评论