Jquery常用时间格式转换

// 时间组件(yyyy-mm-dd hh:mm:ss格式)
function getNowFormatDate() {
var date = new Date();
var seperator1 = "-";
var seperator2 = ":";
var year = date.getFullYear();
var month = date.getMonth() + 1;
var strDate = date.getDate();
if (month >= 1 && month <= 9) {
month = "0" + month;
}
if (strDate >= 0 && strDate <= 9) {
strDate = "0" + strDate;
}
var currentdate = year + seperator1 + month + seperator1 + strDate
+ " " + date.getHours() + seperator2 + date.getMinutes()
+ seperator2 + date.getSeconds();
return currentdate;
}
posted @ 2018-01-24 11:04  火线速递  阅读(489)  评论(0编辑  收藏  举报