本文所分享的知识点是【将中国标准时间转换成标准格式的代码】,欢迎您喜欢我爱IT技术网所分享的教程、知识、经验或攻略,下面是详细的讲解。
将中国标准时间转换成标准格式的代码
function formatTen(num) {
return num > 9 ? (num + "") : ("0" + num);
}
function formatDate(date) {
var year=date.getFullYear();
var month=date.getMonth() + 1;
var day=date.getDate();
var hour=date.getHours();
var minute=date.getMinutes();
var second=date.getSeconds();
return year + "-" + formatTen(month) + "-" + formatTen(day);
}
关于将中国标准时间转换成标准格式的代码的相关讨论如下:
相关问题:c# 时间格式Mon Apr 28 2014 00:00:00 GMT 0800 (...
答:Convert.ToDateTime("Mon Apr 28 2014 00:00:00 GMT 0800".Replace("GMT 0800","")) GMT 0800 代表的是格林威治时间,在中国加8个小时就好了。 >>详细
相关问题:linux下如何把时间转成秒数,或把秒数转换成标准时...
答:转秒用%s date +%s date -d "2014-10-25 11:11:11" +%s 秒转标准时间: date -d "1970-1-1 0:0:0 +1415101567 seconds" date -d @1415101567 >>详细
相关问题:js 获取当前时间格式怎么转换?
答:仅针对这个问题来说,不需要那么大量的代码即可完成 方案1(适用于中国标准时间): var date = new Date(+new Date()+8*3600*1000).toISOString().replace(/T/g,' ').replace(/\.[\d]{3}Z/,'')方案2(只用于题目中所述的格式转换): var date ... >>详细
- 评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)
-
