Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How is Javascript Date handled in other languages?

I don't have the liberty of testing my Javascript on a foreign operating system. I would like to know if the following will work globally:

var d = new Date(
   'Tue Aug 20 2011 16:00:00 GMT-0700 (Pacific Daylight Time)'
);

If a Spanish OS were to run this, would it crash? Would I have to use this instead?

var d = new Date(
   'Mar Ago 20 2011 16:00:00 GMT-0700 (Pacífico Hora de verano)'
);

I use strings to initialize Date because I hate using the numerical approaches which all require translating into UTC.

like image 695
JoJo Avatar asked Aug 16 '11 21:08

JoJo


People also ask

How are JavaScript dates stored?

JavaScript Stores Dates as Milliseconds JavaScript stores dates as number of milliseconds since January 01, 1970, 00:00:00 UTC (Universal Time Coordinated). Zero time is January 01, 1970 00:00:00 UTC.

What date format does JavaScript use?

The preferred Javascript date formats are: Dates Only — YYYY-MM-DD. Dates With Times — YYYY-MM-DDTHH:MM:SSZ.

How does new date work JavaScript?

The Date object is an inbuilt datatype of JavaScript language. It is used to work with dates and times. The Date object is created by using new keyword, i.e. new Date(). The Date object can be used date and time in terms of millisecond precision within 100 million days before or after 1/1/1970.

How do you code a date in JavaScript?

We can create a date using the Date object by calling the new Date() constructor as shown in the below syntax. Syntax: new Date(); new Date(value); new Date(dateString); new Date(year, month, day, hours, minutes, seconds, milliseconds);


1 Answers

No. The string format is strict about language. English only. I have a Hebrew OS and I use English just fine. (Trying Hebrew crashes it).

like image 187
Madara's Ghost Avatar answered Oct 27 '22 03:10

Madara's Ghost