日期时间格式化
程序员文章站
2022-07-02 16:51:20
1 function formatDateTime(date) { 2 var y = date.getFullYear(); 3 var m = date.getMonth() + 1; 4 m = m < 10 ? ('0' + m) : m; 5 var d = date.getDate();... ......
1 function formatdatetime(date) { 2 var y = date.getfullyear(); 3 var m = date.getmonth() + 1; 4 m = m < 10 ? ('0' + m) : m; 5 var d = date.getdate(); 6 d = d < 10 ? ('0' + d) : d; 7 var h = date.gethours(); 8 h=h < 10 ? ('0' + h) : h; 9 var minute = date.getminutes(); 10 minute = minute < 10 ? ('0' + minute) : minute; 11 var second=date.getseconds(); 12 second=second < 10 ? ('0' + second) : second; 13 return y + '-' + m + '-' + d+' '+h+':'+minute+':'+second; 14 }
上一篇: 轻重不可取,食材B2B电商还得脚踏实地
下一篇: 强烈推荐-ajax开发者必看的文章