//获取今天的日期和时间var myDate = new Date(); var year = myDate.getFullYear(); //年var month = myDate.getMonth() + 1;//月var date = myDate.getDate();//日var h = myDate.getHours(); //当前时(0-23)var m = myDate.getMinutes(); //当前分(0-59)var s = myDate.getSeconds();//当前秒(0-59)
//获取明天的日期
var tomorrow = new Date();
tomorrow.setTime(tomorrow.getTime() + 24*60*60*1000);
tomorrow_month = tomorrow.getMonth()+1;//月
tomorrow_date = tomorrow.getDate();//日 //获取当前时间戳
var now_timestamp = myDate.getTime(); //获取指定时间的时间戳 var time = new Date( year, myDate.getMonth(), date, h, m, s);var timestamp = time.getTime() //比较两个时间的大小(先后)if(now_timestamp > timestamp){ alert(‘当前时间大‘);}
原文地址:https://www.cnblogs.com/jdbeyond/p/12079880.html
时间: 2024-10-18 10:12:57