操作日期firefox vs chrome
operations with dates firefox vs chrome
为什么这个减法适用于chrome而不适用于firefox:
if(((new Date()) - (new Date(res.last_connection)))/(1000*60)<12) //12 minits
res.last_connection是一个SQL格式的日期,javascript请求到服务器,它向数据库进行查询,并直接返回结果,类似于:"2015-10-28 23:13:35"。
我想的下一个解决方案是:
if(((new Date()).getTime() - (new Date(res.last_connection.replace(" ", "T"))).getTime())/(1000*60)<12)
空格的替换在firefox上有效,但在chrome上无效。chrome的新问题是时间提前了一个小时。
解决方案
经过长时间的打字和测试(我甚至在上做了一个账户),我想我找到了解决方案:
if(((new Date()).getTime() - (new Date(res.last_connection.replace(/-/g,"/"))).getTime())/(1000*60)<12)
替换斜杠的脚本似乎有效!!:D
谢谢。
相关文章:
- "#"keyCode=222 vs 51(Chrome与Android版Chrome)-为什么有区别
- Chrome vs JS:未捕获的语法错误:意外的令牌)
- 让vs var在nodejs和chrome中的性能
- Javascript canvas.getImageData IE vs Chrome
- 这个关键字在Safaari vs.Chrome,Firefox,IE中具有select box onchange属性
- Chrome 扩展程序 - onRequest/sendRequest vs onMessage/sendMessage
- JavaScript Chrome vs IE
- window.location.pathname Chrome vs Mozilla
- Firefox vs Chrome for iMacros
- window.find() in Firefox vs Chrome
- 在Chrome VS IE9中设置HTML文本输入字段的defaultValue
- AngularJS:使用$timeout在摘要循环后运行(Safari vs chrome)
- 操作日期firefox vs chrome
- 从web开发者的角度来看,Firefox Vs Chrome
- setInterval Chrome vs Firefox
- 背景.html vs.背景.js - chrome扩展
- Javascript event in Chrome vs. Safari
- 范围对象,获取选择父节点Chrome vs Firefox
- Chrome vs. Firefox Extensions
- 发送& # 39;授权# 39;标题在Ext JS Ajax请求,Chrome vs. Firefox