var curTime = new Date();
console.log("%o",curTime);
//把字符串格式转化为日期类
var starttime = new Date("2018-12-11 05:05:05");
var endtime = new Date(Date.parse("2018-12-21 11:11:11"));
console.log("%o",starttime);
console.log("%o",endtime);
console.log("%o",(curTime>=starttime && curTime<=endtime))
另外:
var s1="true";
和var s2=true;是不一样的,前者表示字符串类型,后者表示布尔类型。
参考:
https://blog.youkuaiyun.com/evilcry2012/article/details/50910505