//获取当前时间字符串
function getNowDate(){
var nowTime;
var time = new Date();
var year=time.getFullYear(); //获取完整的年份(4位,1970-???)
var month=time.getMonth()+1; //获取当前月份(0-11,0代表1月)
var date=time.getDate(); //获取当前日(1-31)
var hour=time.getHours(); //获取当前小时数(0-23)
var minute=time.getMinutes(); //获取当前分钟数(0-59)
var seconds=time.getSeconds(); //获取当前秒数(0-59)
if(month<10){
month="0"+month;
}
if(date<10){
date="0"+date;
}
if(hour<10){
hour="0"+hour;
}
if(minute<10){
minute="0"+minute;
}
if(seconds<10){
seconds="0"+seconds;
}
nowTime=year+month+date+hour+minute+seconds+"";
return nowTime;
}
js 获取当前时间 返回14位字符串
最新推荐文章于 2021-12-15 10:02:50 发布