得到一个时间戳,js如何判断时间是否当天,当天显示时间,之前的显示几月几日
new Date(时间戳)
http://www.w3school.com.cn/jsref/jsref_obj_date.asp
我猜你想做时间的加减法?
php
var str = 1404172800000; if (new Date(str).toDateString() === new Date().toDateString()) { //今天 } else if (new Date(str) < new Date()){ //之前 console.log(new Date(str).toISOString().slice(0,10));//2014-07-01 }