javascript new date not working in iphone and android devices with NAN and Undefined error

Today i found a new problem, the date object working perfectly in desktop web browsers but not working in android browsers and iphone browsers. The problem is they issue NAN and Undefined errors. So what is the universal solution? There is a simple solution to the problem. You should declare date as following format:

var date1 = new Date("2016-12-10 07:42");

If you are processing date from php then the format for php date is:

echo "<script>var date1 = \"".date('Y/m/d H:i:s')."\";</script>";

Hope this technique works for web browsers in desktop and mobile devices.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

*