Questions about the invalid date in iOS for new date

Source: Internet
Author: User

var datef=new Date ("2017-2-22 06:23");

JavaScript new Date ("XXXX"), this short code is perfect for Android phones, but the iphone returns invalid date

Information found:

New Date ("2017-2-22 06:23") This time format is not supported on iOS systems

This format can only be changed to the new Date ("2017/2/22 06:23").

or such a format: New Date ("2017", "2", "22", "06", "23")

var datef= "2017-2-22 06:23"; JS does not provide a way to replace all replaceall. Replace all '-' using regular Expressions Datef=datef.replace (/-/g, "/");//ios only supports new date ("2017/2/22 06:23") format var suggest_date = new Date (DATEF) ;//Convert the difference in milliseconds to a number of days, var day = parsefloat ((suggest_date-new date ())/1000/60/60/24);








This article from the "10916470" blog, reproduced please contact the author!

Questions about the invalid date in iOS for new date

Related Article

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.