This experiment was conducted using Chrome 53.
To explore other date fields, I included some options in the DateTimeFormat
:
options = {
year: 'numeric', month: 'numeric', day: 'numeric',
hour: 'numeric', minute: 'numeric', second: 'numeric',
hour12: false, timeZoneName: 'long'
};
var workingDate = Intl.DateTimeFormat('en-GB', options).format(new Date('Fri May 11 1848 01:00:00 GMT+0100 (BST)'));
var notWorkingDate = Intl.DateTimeFormat('en-GB', options).format(new Date('Fri May 11 1847 01:00:00 GMT+0100 (BST)'));
The outcomes were as follows:
workingDate: 10/05/1848, 20:53:32 GMT-03:06:28
notWorkingDate: 10/05/1847, 20:53:32 GMT-03:06:28
Historically, standardized UTC-based offsets were not widespread before 1900 due to varying adoption timelines across different regions. Hence, peculiar results are expected for dates prior to 1900. An explanation provided by Matt in the comments reveals that UTC came into effect in 1972 and prior to that, zones were typically defined as deviations from GMT. Consequently, older dates, especially pre-1900, may exhibit such offset anomalies.
In this instance, the timezone reflects the default setting of my system (America/Sao_Paulo
) producing an offset of -03:06:28
before 1914.
Prior to December 1, 1847, London operated under an offset of -00:01:15
(calculated via lat/lon). Subsequently, the offset changed to +00:00
, explaining why it aligns with 1848 dates.
I repeated the test utilizing the timezone Europe/London
:
options = {
year: 'numeric', month: 'numeric', day: 'numeric',
hour: 'numeric', minute: 'numeric', second: 'numeric',
hour12: false, timeZoneName: 'long', timeZone: 'Europe/London'
};
var workingDate = Intl.DateTimeFormat('en-GB', options).format(new Date('Fri May 11 1848 01:00:00 GMT+0100 (BST)'));
var notWorkingDate = Intl.DateTimeFormat('en-GB', options).format(new Date('Fri May 11 1847 01:00:00 GMT+0100 (BST)'));
The output demonstrated:
11/05/1848, 00:00:00 GMT
10/05/1847, 23:58:45 GMT-00:01:15
This validates the differing offsets present before December 1847.
An effective solution is to treat the date as UTC:
options = {
timeZone: 'UTC'
};
var workingDate = Intl.DateTimeFormat('en-GB', options).format(new Date('Fri May 11 1848 01:00:00 GMT+0100 (BST)'));
var notWorkingDate = Intl.DateTimeFormat('en-GB', options).format(new Date('Fri May 11 1847 01:00:00 GMT+0100 (BST)'));
This approach yields the following outputs:
11/05/1848
11/05/1847