如何获取当前日期:
function CurentTime() { var now = new Date(); var year = now.getFullYear(); //年 var month = now.getMonth() + 1; //月 var day = now.getDate(); //日 var clock = year + "-"; if(month < 10) clock += "0"; clock += month + "-"; if(day < 10) clock += "0"; clock += day + " "; return(clock); } var time_now=CurentTime();//这个是当前时间(日期格式)
当前时间戳:
var timestamp = Date.parse(new Date()); timestamp = timestamp / 1000;