我正在计算两次之间的差。这在chrome和firefox中工作正常,返回毫秒差。它不在Safari中,返回差异为NaN。
var currentdate = new Date();
var myDate = "2018-07-15 21:06:00";
var difference = (currentdate - new Date(myDate))/3600000;
谢谢
答案 0 :(得分:0)
@charlietfl是正确的。尝试使用ISO格式
var currentdate = new Date();
var myDate = "2018-07-15T21:06:00.000Z";
var difference = (currentdate - new Date(myDate))/3600000;