3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $tz = new DateTimeZone('America/Los_Angeles'); $now = new DateTime('now', $tz); $now = new DateTime('03 Nov 2014'); $twoDaysAgo1 = new DateTime('-2 days', $tz); $twoDaysAgo1_1 = $now->sub(new DateInterval('P2D')); $twoDaysAgo2 = new DateTime('-172800 seconds', $tz); $twoDaysAgo2_1 = $now->sub(new DateInterval('PT172800S')); $twoDaysAgo3 = new DateTime('@' . ($now->getTimestamp() - 172800), $tz); //var_dump($twoDaysAgo1->getTimestamp()); var_dump($twoDaysAgo1_1->getTimestamp()); var_dump($twoDaysAgo2->getTimestamp()); var_dump($twoDaysAgo2_1->getTimestamp()); var_dump($twoDaysAgo3->getTimestamp());
based on BYMKa
Output for 5.6.28, 7.0.14 - 7.1.0
int(1414623600) int(1414876186) int(1414623600) int(1414450800)
Output for 7.0.6
int(1414623600) int(1462084041) int(1414623600) int(1414450800)
Output for 7.0.5
int(1414623600) int(1459452215) int(1414623600) int(1414450800)
Output for 7.0.4
int(1414623600) int(1457419408) int(1414623600) int(1414450800)
Output for 7.0.3
int(1414623600) int(1458112611) int(1414623600) int(1414450800)
Output for 7.0.2
int(1414623600) int(1458478939) int(1414623600) int(1414450800)
Output for 7.0.1
int(1414623600) int(1458583454) int(1414623600) int(1414450800)
Output for 7.0.0
int(1414623600) int(1458848419) int(1414623600) int(1414450800)
Output for 5.6.21
int(1414623600) int(1461980845) int(1414623600) int(1414450800)
Output for 5.6.20
int(1414623600) int(1460053013) int(1414623600) int(1414450800)
Output for 5.6.19
int(1414623600) int(1457189441) int(1414623600) int(1414450800)
Output for 5.6.18
int(1414623600) int(1457825792) int(1414623600) int(1414450800)
Output for 5.6.17
int(1414623600) int(1458214503) int(1414623600) int(1414450800)
Output for 5.6.16
int(1414623600) int(1458937574) int(1414623600) int(1414450800)
Output for 5.6.15
int(1414623600) int(1459027151) int(1414623600) int(1414450800)
Output for 5.6.14
int(1414623600) int(1459381970) int(1414623600) int(1414450800)
Output for 5.6.13
int(1414623600) int(1460519310) int(1414623600) int(1414450800)
Output for 5.6.12
int(1414623600) int(1460914017) int(1414623600) int(1414450800)
Output for 5.6.11
int(1414623600) int(1461198497) int(1414623600) int(1414450800)
Output for 5.6.10
int(1414623600) int(1461377817) int(1414623600) int(1414450800)
Output for 5.6.9
int(1414623600) int(1461568467) int(1414623600) int(1414450800)
Output for 5.6.8
int(1414623600) int(1461770153) int(1414623600) int(1414450800)
Output for 5.6.7
int(1414623600) int(1463998393) int(1414623600) int(1414450800)
Output for 5.5.35
int(1414623600) int(1463722192) int(1414623600) int(1414450800)
Output for 5.5.34
int(1414623600) int(1460148013) int(1414623600) int(1414450800)
Output for 5.5.33
int(1414623600) int(1457285968) int(1414623600) int(1414450800)
Output for 5.5.32
int(1414623600) int(1458001690) int(1414623600) int(1414450800)
Output for 5.5.31
int(1414623600) int(1458310905) int(1414623600) int(1414450800)
Output for 5.5.30
int(1414623600) int(1459294034) int(1414623600) int(1414450800)
Output for 5.5.29
int(1414623600) int(1460656427) int(1414623600) int(1414450800)
Output for 5.5.28
int(1414623600) int(1461011582) int(1414623600) int(1414450800)
Output for 5.5.27
int(1414623600) int(1461107068) int(1414623600) int(1414450800)
Output for 5.5.26
int(1414623600) int(1461472973) int(1414623600) int(1414450800)
Output for 5.5.25
int(1414623600) int(1461667593) int(1414623600) int(1414450800)
Output for 5.5.24
int(1414623600) int(1463852872) int(1414623600) int(1414450800)
Output for 5.4.45
int(1414623600) int(1441428417) int(1414623600) int(1414450800)
Output for 5.4.44
int(1414623600) int(1441428414) int(1414623600) int(1414450800)
Output for 5.4.43
int(1414623600) int(1441428411) int(1414623600) int(1414450800)
Output for 5.4.42
int(1414623600) int(1441428410) int(1414623600) int(1414450800)
Output for 5.4.41
int(1414623600) int(1441428408) int(1414623600) int(1414450800)
Output for 5.4.40
int(1414623600) int(1441428406) int(1414623600) int(1414450800)
Output for 5.4.39
int(1414623600) int(1441428405) int(1414623600) int(1414450800)
Output for 5.4.38
int(1414623600) int(1441428403) int(1414623600) int(1414450800)
Output for 5.4.37
int(1414623600) int(1441428402) int(1414623600) int(1414450800)
Output for 5.4.36
int(1414623600) int(1441428401) int(1414623600) int(1414450800)
Output for 5.4.35
int(1414623600) int(1441428400) int(1414623600) int(1414450800)
Output for 5.4.20 - 5.4.34
int(1414623600) int(1414876191) int(1414623600) int(1414450800)
Output for 5.3.28 - 5.4.19
int(1414623600) int(1414876192) int(1414623600) int(1414450800)
Output for 5.3.7 - 5.3.27
int(1414623600) int(1414876193) int(1414623600) int(1414450800)
Output for 5.3.3 - 5.3.6
int(1414623600) int(1414876194) int(1414623600) int(1414450800)
Output for 5.3.0 - 5.3.2
int(1414274400) int(1414876194) int(1414101600) int(1414278000)
Output for 5.2.0 - 5.2.17
Fatal error: Call to undefined method DateTime::sub() in /in/KWH8G on line 6
Process exited with code 255.
Output for 5.0.0 - 5.1.6
Fatal error: Class 'DateTimeZone' not found in /in/KWH8G on line 2
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: datetimezone in /in/KWH8G on line 2
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: datetimezone in /in/KWH8G on line 2