如何获取当前日期:
1 function CurentTime() 2 { 3 var now = new Date(); 4 5 var year = now.getFullYear(); //年 6 var month = now.getMonth() + 1; //月 7 var day = now.getDate(); //日 8 9 var clock = year + "-"; 10 11 if(month < 10) 12 clock += "0"; 13 14 clock += month + "-"; 15 16 if(day < 10) 17 clock += "0"; 18 19 clock += day + " "; 20 21 return(clock); 22 } 23 24 var time_now=CurentTime();//这个是当前时间(日期格式)
当前时间戳:
1 var timestamp = Date.parse(new Date()); 2 timestamp = timestamp / 1000;
时间: 2024-10-06 03:12:54