I am trying get difference of two time in safari browser .It is working fine in chrome .But on safari I am getting NAN.when I run application I save today date first time.and on second time I run my application I get the difference of save date and now date .it give correct in chrome .but fail in safari why ? here is my code http://ift.tt/1KNZ7nL
var todaydate = new Date();
var datetime = todaydate.getMonth() + 1 + "-" + todaydate.getDate() + "-" + todaydate.getFullYear() + " " + todaydate.getHours() + ":" + todaydate.getMinutes() + ":" + todaydate.getSeconds();
if (localStorage.getItem("getSinkdate") == null || localStorage.getItem("getSinkdate") == '') {
alert('empty')
localStorage.setItem("getSinkdate", datetime);
} else {
var datetimeLocal = window.localStorage.getItem("getSinkdate")
var d1 = new Date(datetime);
var d2 = new Date(datetimeLocal);
alert((d2.getTime() - d1.getTime()) / (1000 * 3600))
alert((d2.getTime() - d1.getTime()) / (1000 * 3600) > 12)
if ((d2.getTime() - d1.getTime()) /(1000*3600)> 12)
{
alert((d2.getTime() - d1.getTime())/ (1000 * 3600));
localStorage.setItem("getSinkdate", datetime);
}
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire