js date对象之setTime()和getTime()+co
2019-04-08 本文已影响0人
luguilun
var exp=new Date();
setTime(a毫秒):从1970年1月1日午夜到设置的日期已经走了a毫秒。
例如:
var exp=new Date();
exp.setTime(3000)//设置为exp的日期为:从1970.1.1开始已经走了3000毫秒
var exp=new Date();
console.log(exp.toGMTString())
exp.setTime(24*60*60*1000)//设置为exp的日期为:从1970.1.1开始已经走了24*60*60*1000毫秒,即走了一天
//则exp为exp.toGMTString()
console.log(exp.toGMTString())

getTime():获取970年1月1日午夜到exp的毫秒数。
延伸
cookie的expires的正确用法
https://blog.csdn.net/xuchanghao/article/details/5865928
js获取cookie
https://jingyan.baidu.com/article/9113f81b1784f52b3214c713.html##1