I've developed a weird obsession with the first world war. I have a countdown clock to the 100th anniversary of the war. This clock is intended to countdown to 11:10 AM in Vienna on July 28th, 1914. This is when Austro-Hungary telegraphed its declaration of war to Serbia.I occasionally like to tweet or display events exactly 100 years after they originally occurred (e.g., Princip shoots Franz Ferdinand).
The problem I'm having is one of time zones. I noticed a difference of one hour between my live tweets and those of the BBC and thought perhaps the BBC might have goofed with the timezone somehow but was corrected by someone who said "Sarajevo now has DST but was on GMT+1 in 1914 - the same as BST today". I'm wondering if there is some way to verify this and also wondering if there is some orderly, programmatic way to convert dates/times I read in history books (like this excellent one) into an exact 100-years-later time in Los Angeles.
I'm using the PHP [man]DateTime[/man] functions, but I don't think these take into account any historical changes in the time-keeping policies of the various regions. For example, this script says that these functions think there's an hour time difference between London and Vienna in 1914:
$tz = new DateTimeZone("Europe/Sarajevo");
$dt = new DateTime("1914-07-28 11:10:00", $tz);
echo $dt->getTimestamp() . "<br>";
$tz2 = new DateTimeZone("Europe/London");
$dt2 = new DateTime("1914-07-28 11:10:00", $tz2);
echo $dt2->getTimestamp() . "<br>";
echo "difference: " . ($dt->getTimestamp() - $dt2->getTimestamp()) . "<br>";
The result:
-1749217800
-1749214200
difference: -3600
The time difference is one hour then. The difference is also one hour now:
$tz = new DateTimeZone("Europe/Sarajevo");
$dt = new DateTime("2014-07-13 00:00:00", $tz);
echo $dt->getTimestamp() . "<br>";
$tz2 = new DateTimeZone("Europe/London");
$dt2 = new DateTime("2014-07-13 00:00:00", $tz2);
echo $dt2->getTimestamp() . "<br>";
echo "difference: " . ($dt->getTimestamp() - $dt2->getTimestamp()) . "<br>";
result:
1405202400
1405206000
difference: -3600
This is getting confusing to me because I don't know if London observed DST then or whether Sarajevo was observing DST or not and how this might result in the same one-hour time difference we see today. If anyone can help me get a grip on this, I'd appreciate it.
Observations:
If neither Sarajevo nor London observed DST in 1914, and Sarajevo was GMT+1 then, the one-hour difference calculated for 1914 makes sense.
If London was observing DST in 1914 and Sarajevo was not, the times should be the same.
Curiously, the Wikipedia entry on DST says that DST was first used in WW1:
Starting on 30 April 1916, Germany and its World War I allies (Austria-Hungary) were the first to use DST (German: Sommerzeit) as a way to conserve coal during wartime. Britain, most of its allies, and many European neutrals soon followed suit. Russia and a few other countries waited until the next year and the United States adopted it in 1918.
A google translation of the German page on Sommerzeit says:
The determination was first introduced to "The May 1, 1916 will begin on April 30, 1916 in the afternoon 11 clock after the current era. The September 30, 1916 ending one hour after midnight the purposes of this Regulation ".
This suggests I could be headed for an exceedingly complex situation if I want to be accurate about this. Perhaps there is some test we can do to find a discontinuity in the PHP DateTime calculations (e.g., calculate some German timestamps on April 30, 1916 and look for discontinuities. Actually, let me try that:
for($h=0; $h<24; $h++) {
for($m=0; $m<60; $m++) {
for($s=0; $s<60; $s++) {
// calculate timestamp for $s and $s+1 and compare
$tz = new DateTimeZone("Europe/Berlin");
$datetime1 = "1916-04-30 " . str_pad($h, 2, "0", STR_PAD_LEFT) . ":" . str_pad($m, 2, "0", STR_PAD_LEFT) . ":" . str_pad($s, 2, "0", STR_PAD_LEFT);
$dt1 = new DateTime($datetime1, $tz);
$ts1 = $dt1->getTimestamp() . "<br>";
$datetime2 = "1916-04-30 " . str_pad($h, 2, "0", STR_PAD_LEFT) . ":" . str_pad($m, 2, "0", STR_PAD_LEFT) . ":" . str_pad($s+1, 2, "0", STR_PAD_LEFT);
$dt2 = new DateTime($datetime2, $tz);
$ts2 = $dt2->getTimestamp();
if (($ts2-$ts1) !== 1){
echo "discontinuity found<br>";
echo $dt1->format("Y-m-d H:i:s") . " : " . $dt1->getTimestamp() . "<br>";
echo $dt2->format("Y-m-d H:i:s") . " : " . $dt2->getTimestamp() . "<br>";
echo "The second time is " . ($dt2->getTimestamp() - $dt1->getTimestamp()) . " greater than the first<br>";
}
}
}
}
Wow! It looks like the PHP DateTime function does show a one-hour leap in 1916 in Berlin time:
1916-04-30 23:59:59 : -1693702801
1916-05-01 00:00:00 : -1693706400
The second time is -3599 greater than the first
I'm a little confused that this seems to be a leap back on the clock in springtime? These timestamps are negative (i.e., prior to 1970) and so the May 1 timestamp seems to be 'falling back' rather than 'leaping forward' as we usually do in spring??