The difference between Chrome and Firefox for time processing

Source: Internet
Author: User

The new Date () function to pass parameters, in Firefox and Google browser console run, will get different results, just start to feel impossible, and then the actual operation found this trap.

In Firefox:

var dstring = "2015-06-22 16:40:18";

var dTime = new Date (dstring);

There is no result date, and chrome can normally be converted to a date type. While

var date = newDate(‘2014-07-25T23:00:00‘);

alert(date);The results are also different in two browsers.

In contrast, the Google browser takes the string passed in as UTC time, plus 8 hours (Beijing is in the East eight), and the new Date () is called the Date.parse (' 2014-07-25t23:00:00z ') function.

While Firefox is not automatically added as a local time zone, the UTC format string in Firefox is finally added with Z (z for Zulu, GMT).

Of course, you can also add a 0 time zone offset "+00:00", such as ' 2014-07-25t23:00:00+00:00 ', at the end of the UTC string.

The new date () in Firefox does not support the horizontal-representation date format, which can be converted to/from the format and then to new.

The difference between Chrome and Firefox for time processing

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.