首页 > 代码库 > 时间相关

时间相关

//拼接年月日时分秒  格式为:2015-03-02 13:25:02
function getFllTime(){
var date = new Date();

//月份
var month = date.getMonth()>=0 && date.getMonth()<=9?"0"+(date.getMonth()+1):(date.getMonth()+1);

//日期
var day = date.getDate()>=0 && date.getDate()<=9 ? "0"+date.getDate():date.getDate();

//时
var hours = date.getHours()>=0 && date.getHours()<=9 ? "0"+date.getHours():date.getHours();

//分
var minutes = date.getMinutes()>=0 && date.getMinutes()<=9 ? "0"+date.getMinutes():date.getMinutes();

//秒
var seconds = date.getSeconds()>=0 && date.getSeconds()<=9 ? "0"+date.getSeconds():date.getSeconds();

var createdate = date.getFullYear() +"-"+ month +"-"+ day +" "+ hours +":"+ minutes +":"+ seconds;
return createdate;
}

时间相关