
This document demonstrates an apparent flaw in the Opera Web browser. Most of the constructor formats for the Date object fail to properly create and initialize a Date object.
The JavaScript code demonstrated here consists of several blocks of statements similar to the following:
var tdate;
document.write ("<P>Constructor: Date (year, month, day, hour, minute, second, ms)<BR>");
tdate = new Date (1998, 4, 26, 8, 0, 0, 0);
document.write (tdate.toString () + "<BR>");
document.write (tdate.getTime ());
You can view the document source to see all of the JavaScript code.
All of the examples below should indicate 26 May 1998. Examples that included a time specification should show 08:00 AM local time.
When this document is loaded in Opera, however, all of the Date objects except for the last one display either the current date and time or an erroneous value. Only the constructor that uses a string value results in the correct value.
The following examples use a 4-digit date (1998):
The following examples use a 2-digit date (98):