前端获得的本地时间(设备时间)不必定是准确的,由于用户有可能故意修改时间,用这个不必定准确的时间作一些校验每每不靠谱。
通常获取服务端时间,都是经过接口让后端返回的,其实,也有方法在前端直接获取服务端的时间。前端
var req = new XMLHttpRequest(); req.open('GET', location, false); req.send(null); console.log(req.getResponseHeader('Date'));