Invalid date appears on iOS on new date,

Source: Internet
Author: User

With angular Ngmodel binding time, in the Android debugging no problem, did not expect to appear on iOS Nan:nan, the background dropped the data is probably like this 2016-03-08 20:14

However, the problem is on the delimiter "-", as if Safari did not implement this standard, you can see here Http://stackoverflow.com/questions/4310953/invalid-date-in-safari

So this can be achieved, I intercept the answer from the link:

var myDate1 = date.parseexact ("29-11-2010", "dd-mm-yyyy"), var myDate2 = date.parseexact ("11-29-2010", "mm-dd-yyyy"); var myDate3 = date.parseexact ("2010-11-29", "Yyyy-mm-dd"), var myDate4 = date.parseexact ("2010-29-11", "yyyy-dd-mm");

Or just like this:

New Date (' 2015-03-08 20:18 '. Replace (/-/g, "/"))

:) Done,

Invalid date appears on iOS on new date,

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.