js得到當前日期,美中不足的是日期格式若是前面是個位數,則前面零不顯示;php
獲取日期:ide
var myDate = new Date(); var datetime=myDate.getFullYear()+'-'+(myDate.getMonth()+1)+'-'+myDate.getDate()+' '+myDate.getHours()+':'+myDate.getMinutes()+':'+myDate.getSeconds(); alert(datetime);
獲取時間戳:get
var timestamp = (new Date()).valueOf();
日期轉換時間戳:it
var timestamp2 = Date.parse(new Date(vals)); vals = timestamp2 /1000;