标签:minutes return details mes tail function turn cti 标准
1、将中国标准时间格式化为(2017-06-06 15:05:04)
function formatDateTime(theDate) {
var _hour = theDate.getHours();
var _minute = theDate.getMinutes();
var _second = theDate.getSeconds();
var _year = theDate.getFullYear()
var _month = theDate.getMonth();
var _date = theDate.getDate();
if(_hour<10){_hour="0"+_hour ;}
if(_minute<10){_minute="0"+_minute; }
if(_second<10){_second="0"+_second }
_month = _month + 1;
if(_month < 10){_month = "0" + _month;}
if(_date<10){_date="0"+_date }
return _year + "-" + _month + "-" + _date + " " + _hour + ":" + _minute + ":" + _second ;
}
var time = new Date();
var formatTime = formatDateTime(time );
返回结果:
Tue Jun 06 2017 15:31:09 GMT+0800 (中国标准时间)
2017-06-06 15:31:09
2、把格式化时间转换为毫秒数
var formatTimeS = new Date(‘2017-06-06 15:31:09‘).getTime();
返回结果:1496734269900
3、把毫秒数转换为标准时间
var formatTimeS = new Date(1496734269900);
返回结果:
Tue Jun 06 2017 15:31:09 GMT+0800 (中国标准时间)
---------------------
作者:木雷双雄7
来源:CSDN
原文:https://blog.csdn.net/wlangmood/article/details/72879607
版权声明:本文为博主原创文章,转载请附上博文链接!
标签:minutes return details mes tail function turn cti 标准
原文地址:https://www.cnblogs.com/CHWLearningNotes/p/10333156.html