开发者

Date object javascript

开发者 https://www.devze.com 2022-12-23 02:43 出处:网络
var date = new Date();//Mon Mar 15 2010 12:40:05 GMT+0300 (MSK) var omg = date.getDate() + 19;// 34 date.setDate(omg);

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()
0

精彩评论

暂无评论...
验证码 换一张
取 消