Safari conversion timestamp problem in iOS

Source: Internet
Author: User

Background issued by the time format such as: 2016-09-15 15:30:10;
Not much, just use the new date (' 2016-09-15 15:30:10 '). GetTime () gets the timestamp;
Development time, computer debugging OK, when put to touch screen debugging, Androidok, but iOS also die, the result is: Nan-nan1-nan Invalid Date
What?
Later learned: iOS can read the format is: 2016/09/15 15:30:10
Well, that one is written as a uniform method of converting timestamps to invoke:

Exports.exchangetime = function (date) {        if (date) {            //2016-09-15 15:30:10            var date_1 = date.split (') [0],                date_2 = Date.split (") [1];            var y = date_1.split ('-') [0],                m = date_1.split ('-') [1],                d = date_1.split ('-') [2],                h = date_2.split (': ') [0],                i = date_2.split (': ') [1],                s = date_2.split (': ') [2];        } else{            var now_date = new Date ();            var y = now_date.getfullyear (),                m = now_date.getmonth () + 1,                d = now_date.getdate (),                h = now_date.gethours (),                i = now_date.getminutes (),                s = now_date.getseconds ();        }        return Date.utc (Y, M, D, H, I, s);    }

  

Safari conversion timestamp problem in iOS

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.