首页 > 其他 > 详细

日期和时间1

时间:2015-03-14 23:04:31      阅读:349      评论:0      收藏:0      [点我收藏+]
/*

var box = new Date(2007, 10, 15, 17, 22, 45, 15);
alert(box);                                                                    //Thu Nov 15 2007 17:22:45 GMT+0800
alert(‘toString:‘ + box.toString());                                    //Thu Nov 15 2007 17:22:45 GMT+0800 
alert(‘toLocaleString:‘ + box.toLocaleString());                //2007-11-15 17:22:45 PS谷歌返回的Thu Nov 15 2007 17:22:45 GMT+0800 
alert(‘valueOf:‘ + box.valueOf());                                    //1195118565015


var box = new Date(2007, 10, 15, 17, 22, 45, 15);
alert(box.toDateString());
alert(box.toTimeString());
alert(box.toLocaleDateString());
alert(box.toLocaleTimeString());
alert(box.toUTCString());

box.setTime(100);
alert(box.getTime());
alert(box.getYear());//废弃
box.setFullYear(2009);
alert(box.getFullYear());
box.setMonth(5);
alert(box.getMonth());

var box = new Date();
alert(box.getMonth() + 1);

alert(box.getMonth() + 1); //月份要加1才是最终的月份

box.setUTCFullYear(2008);
alert(box.getUTCFullYear());

alert(box.getUTCHours()); //东八区有8个小时的差距
所有getUTCHous和getHous相差8个小时

var box = new Date(2007, 10, 15, 10, 22, 45, 15);
alert(box.getTimezoneOffset());
*/




var box = new Date();
alert(box.getFullYear() + ‘-‘ + box.getMonth() + ‘-‘ + box.getDate() + ‘ ‘ + box.getHours() + ‘:‘ + box.getMinutes() + ‘:‘ + box.getSeconds());

 

日期和时间1

原文:http://www.cnblogs.com/laugh/p/4338466.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!