6
I’m creating some parsers
and was doing some tests to develop Date’s.
This code:
value = '2015-12-31 23:16:00'
value = value.replace(/(\d{4}-\d{2}-\d{2}) ?(\d{2}:\d{2})?(:\d{2})?.*/, '$1T$2$3');
value = value.replace(/T$/, '');
value = value.replace(/(:\d{2})$/, '$1Z');
value = new Date(value)
runs correctly on Firefox, returning Date 2015-12-31T23:16:00.000Z
, however in Chrome it displays Thu Dec 31 2015 21:16:00 GMT-0200 (BRST)
In addition to displaying differently, Chrome killed two hours of the original time.
Would anyone know how to turn this around?
without the 'Z' worked properly here in my
Chrome
, maybe I’ll give you a little something http://stackoverflow.com/questions/15109894/new-date-works-differently-in-chrome-and-firefox– Maicon Carraro
@Maiconcarraro actually I had already found this reference, from
Z
at the end, and I’m applying it, if you comment on mine that hasvalue = new Date(value)
value displayed in the sera console,"2015-12-31T23:16:00Z"
, however still remains a difference of two hours in theChrome
– Guilherme Lautert
By my tests there is no problem at the time, it is only their display that is divergent in the browsers. In both running the
getUTCHours()
, returned me23
. As in other functions.– Guilherme Lautert