July 4, 2000 - Converting Dates to Strings | WebReference

July 4, 2000 - Converting Dates to Strings

Yehuda Shiran July 4, 2000
Converting Dates to Strings
Tips: July 2000

Yehuda Shiran, Ph.D.
Doc JavaScript

Internet Explorer 5.5 updated the toLocaleString() method for the objects Date, Number, and Array so they all retrieve formatting information from the user's Control Panel settings. The Date printout is determined by the Date tab of the Control Panel's Regional Settings:

and by the Time tab:

If we define x, for example, as:

x = new Date();

then the command alert(x.toLocaleString()) will generate the following box:

Notice how the format is as specified in the Regional Settings under the Date tab above, for Internet Explorer 5.5. For previous versions of IE and for pre 6 versions of Netscape Navigator, dates are formatted according to a single specification that you don't have control over. In Netscape Navigator 4.08, for example, the format is as shown above, but without the AM/PM indication.