//格式化為時(shí)間字符串 yyyy-mm-dd hh:mm:ssfunction strDate(date, type) {
var y = date.getFullYear(),
m1= date.getMonth() + 1,
d= date.getDate();
var h = date.getHours(),
m2= date.getMinutes(),
s= date.getSeconds();
var str = '';
switch (type) {
case 'y-m-d':
str= y + '-' + m1 + '-' + d;
break;
case 'h:m':
str= h + ':' + m2;
break;
default:
str= y + '-' + m1 + '-' + d + ' ' + h + ':' + m2
break;
}
console.log(str);
return str;
}
strDate(new Date(1419580954141));
標(biāo)準(zhǔn)時(shí)間計(jì)算方法:new Date();
創(chuàng)新互聯(lián)公司“設(shè)計(jì)定江山,服務(wù)贏天下“的思想,用細(xì)節(jié)和態(tài)度獲得客戶(hù)的認(rèn)可與同行的尊重,服務(wù)是創(chuàng)新互聯(lián)公司企業(yè)文化中重要的核心思想,每一位員工要致力成為客戶(hù)心中堅(jiān)實(shí)的服務(wù)后盾。也可以 new Date(時(shí)間戳);
// 帶有data-validate='number'的input只能輸入數(shù)字$(document).on("input", "input[data-validate='number']", function () {
$(this).val($(this).val().replace(/[^0-9]/g, ''));
});
function changeTimeFormat(time) {
time= parseInt(time);
var date = new Date(time);
var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
var hh = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
var mm = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
var ss = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
return date.getFullYear() + "-" + month + "-" + currentDate + " " + hh + ":" + mm + ":" + ss;
}