700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > yyyy-MM-dd 转化成 中国标准时间(Tue Dec 31 00:00:00 GMT+0800 (中国标准时间))

yyyy-MM-dd 转化成 中国标准时间(Tue Dec 31 00:00:00 GMT+0800 (中国标准时间))

时间:2021-02-27 09:16:05

相关推荐

yyyy-MM-dd 转化成 中国标准时间(Tue Dec 31  00:00:00 GMT+0800 (中国标准时间))

时间戳 、yyyy-MM-dd 格式都可以通过 new Date()转换成中国标准时间: Tue Dec 31 00:00:00 GMT+0800 (中国标准时间)

new Date()的参数可以为空,也可以为以下几种:

1、new Date(“month dd,yyyy hh:mm:ss”);

2、new Date(“month dd,yyyy”);

3、new Date(yyyy,mth,dd,hh,mm,ss); 注意:这种方式下,必须传递整型;

4、new Date(yyyy,mth,dd);

5、new Date(ms); 注意:ms:是需要创建的时间和 GMT时间1970年1月1日之间相差的毫秒数;当前时间与GMT1970.1.1之间的毫秒数:var mills = new Date().getTime();

ps:因为月份是0-11(代表1-12月份),所以有时记得减去1 ,例如:new Date(,6,9),显示在日期选择器上就是-7-9,要想显示正确,就应该为 new Date(,6-1,9),也就是 new Date(,5,9),这样日期选择器上就是-6-9

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。