<?php
$str = "Tue, 10 Apr 2012 11:27:56 +0300";
$d1 = new DateTime($str);
$d2 = new DateTime;
$d2->modify($str);
$t1 = $d1->getTimestamp();
$t2 = $d2->getTimestamp();
$tz1 = $d1->getTimezone()->getName();
$tz2 = $d2->getTimezone()->getName();
$f1 = $d1->format(DateTime::RFC2822);
$f2 = $d2->format(DateTime::RFC2822);
var_dump(compact('t1', 't2', 'tz1', 'tz2', 'f1', 'f2'));
- Output for 5.3.6 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.36, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.7, 7.2.29 - 7.2.33, 7.3.12 - 7.3.31, 7.4.0 - 7.4.25, 7.4.27 - 7.4.33, 8.0.0 - 8.0.12, 8.0.14 - 8.0.30, 8.1.0 - 8.1.14, 8.1.18 - 8.1.28, 8.2.0 - 8.2.1, 8.2.5 - 8.2.18, 8.3.0 - 8.3.6
- array(6) {
["t1"]=>
int(1334046476)
["t2"]=>
int(1334050076)
["tz1"]=>
string(6) "+03:00"
["tz2"]=>
string(16) "Europe/Amsterdam"
["f1"]=>
string(31) "Tue, 10 Apr 2012 11:27:56 +0300"
["f2"]=>
string(31) "Tue, 10 Apr 2012 11:27:56 +0200"
}
- Output for 8.1.15 - 8.1.17, 8.2.2 - 8.2.4
- array(6) {
["t1"]=>
int(1334046476)
["t2"]=>
int(1334046476)
["tz1"]=>
string(6) "+03:00"
["tz2"]=>
string(6) "+03:00"
["f1"]=>
string(31) "Tue, 10 Apr 2012 11:27:56 +0300"
["f2"]=>
string(31) "Tue, 10 Apr 2012 11:27:56 +0300"
}
- Output for 7.3.32 - 7.3.33, 7.4.26, 8.0.13
- array(6) {
["t1"]=>
int(1334046476)
["t2"]=>
int(1334057276)
["tz1"]=>
string(6) "+03:00"
["tz2"]=>
string(3) "UTC"
["f1"]=>
string(31) "Tue, 10 Apr 2012 11:27:56 +0300"
["f2"]=>
string(31) "Tue, 10 Apr 2012 11:27:56 +0000"
}
- Output for 5.3.0 - 5.3.5
- array(6) {
["t1"]=>
int(1334046476)
["t2"]=>
int(1354052843)
["tz1"]=>
string(6) "+03:00"
["tz2"]=>
string(16) "Europe/Amsterdam"
["f1"]=>
string(31) "Tue, 10 Apr 2012 11:27:56 +0300"
["f2"]=>
string(31) "Tue, 27 Nov 2012 22:47:23 +0100"
}
- Output for 5.2.0 - 5.2.17
- Fatal error: Call to undefined method DateTime::getTimestamp() in /in/vkVJ1 on line 9
Process exited with code 255. - Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6
- Fatal error: Class 'DateTime' not found in /in/vkVJ1 on line 5
Process exited with code 255. - Output for 4.4.2 - 4.4.9
- Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /in/vkVJ1 on line 11
Process exited with code 255. - Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
- Parse error: parse error, unexpected T_OBJECT_OPERATOR in /in/vkVJ1 on line 11
Process exited with code 255. - Output for 4.3.2 - 4.3.4
- Parse error: parse error in /in/vkVJ1 on line 11
Process exited with code 255.
preferences:
231.46 ms | 401 KiB | 344 Q