X
Kliknite sem pre prechod na mobilnú verziu webu.

Fórum podpory

Date function returns the date with a day lesser in firefox

Pridané

new Date("10/29/2018") Return output:Date 2018-10-28T18:30:00.000Z

new Date("10/29/2018") Return output:Date 2018-10-28T18:30:00.000Z

Ďalšie informácie o systéme

Nainštalované zásuvné moduly

  • Shockwave Flash 31.0 r0

Aplikácie

  • Identifikácia prehliadača: Mozilla/5.0 (X11; Linux x86_64; rv:64.0) Gecko/20100101 Firefox/64.0

Viac informácií

WestEnd 60 riešení 5387 odpovedí

How are you using the command to see the output?

How are you using the command to see the output?

Upravil(a) WestEnd dňa

jscher2000
  • Top 10 Contributor
8792 riešení 71903 odpovedí

Consider time zones. The "Z" in your output indicates GMT time.

As an example of how to get local time, submit this in Firefox's Web Console:

var d=new Date("10/29/2018"); 
console.log('toString() => ' + d.toString()); 
console.log('toISOString() => ' + d.toISOString()); 
console.log('toLocaleString() => '+d.toLocaleString()); 
console.log('toGMTString() => ' + d.toGMTString());

https://developer.mozilla.org/docs/Tools/Web_Console

I get:

toString() => Mon Oct 29 2018 00:00:00 GMT-0700 (Pacific Daylight Time)

toISOString() => 2018-10-29T07:00:00.000Z

toLocaleString() => 10/29/2018, 12:00:00 AM

toGMTString() => Mon, 29 Oct 2018 07:00:00 GMT

Consider time zones. The "Z" in your output indicates GMT time. As an example of how to get local time, submit this in Firefox's Web Console: <pre>var d=new Date("10/29/2018"); console.log('toString() => ' + d.toString()); console.log('toISOString() => ' + d.toISOString()); console.log('toLocaleString() => '+d.toLocaleString()); console.log('toGMTString() => ' + d.toGMTString()); </pre> https://developer.mozilla.org/docs/Tools/Web_Console I get: toString() => Mon Oct 29 2018 00:00:00 GMT-0700 (Pacific Daylight Time) toISOString() => 2018-10-29T07:00:00.000Z toLocaleString() => 10/29/2018, 12:00:00 AM toGMTString() => Mon, 29 Oct 2018 07:00:00 GMT