javascriptgettime

How to fix getting time in Safari for Javascript


When getting the time in Chrome and Firefox I get the number of milliseconds for a given date, but for Safari it Shows NaN. Any ideas why this would happen? I would need it to show also the number of milliseconds -as well- in Safari.

PHP code

$date = $product->getDateEnd(); 

Javascript:

var countDownDate = new Date("<?php echo $date ?>").getTime();

Solution

  • I guess you got tis pattern yyyy-mm-dd. This isn't an officially supported Date pattern, some browsers like Chrome and Firefox will support it, but Safari not. Try to use other versions, like :

    yyyy/mm/dd mm/dd/yyyy mm-dd-yyyy