javascript new date not working in iphone and android devices with NAN and Undefined error
- Saturday, December 10, 2016, 14:02
- Android, How-to, IOS, Javascript, PHP
- Add a comment
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:
1 |
var date1 = new Date("2016-12-10 07:42"); |
If you are processing date from php then the format for php date is:
1 |
echo "<script>var date1 = \"".date('Y/m/d H:i:s')."\";</script>"; |
Hope this technique works for web browsers in desktop and mobile devices.
About the Author
Write a Comment
Gravatars are small images that can show your personality. You can get your gravatar for free today!