检查日期是否少于1小时前?
2022-08-30 05:09:25
有没有办法检查日期是否少于1小时前?
// old date
var olddate = new Date("February 9, 2012, 12:15");
// current date
var currentdate = new Date();
if (olddate >= currentdate - 1 hour) {
alert("newer than 1 hour");
else {
alert("older than 1 hour");
}
另外,不同的问题 - 有没有办法在这样的日期中添加小时数?
var olddate = new Date("February 9, 2012, 12:15") + 15 HOURS; // output: February 10, 2012, 3:15