标签:style io 2014 art cti ar 时间 new
function getDateDiff(datetime) {
var dateBegin = new Date(datetime.replace(/-/g, "/"));
var dateEnd = new Date();
var dateDiff = dateEnd.getTime() - dateBegin.getTime();
// 计算相差的天数
var dayDiff = Math.floor(dateDiff / (24 * 3600 * 1000));
if( dayDiff < 1) {
var parttime = datetime.substring(11);
var minuteleft = Math.floor(dateDiff / (60 * 1000)); //计算相差的分钟数
if(minuteleft > 10) { //更改此位置的数字 代表相差的分钟数
return 1;
} else {
return 0;
}
} else {
return 1;
}
}
var time = GetDateDiff(‘2014-08-04 11:56:12‘);
console.log(time, ‘---time---‘);
标签:style io 2014 art cti ar 时间 new
原文地址:http://my.oschina.net/felumanman/blog/297736