3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class MyDateTime extends DateTime { public function setTimestamp( $timestamp ) { $date = getdate( ( int ) $timestamp ); $this->setDate( $date['year'] , $date['mon'] , $date['mday'] ); $this->setTime( $date['hours'] , $date['minutes'] , $date['seconds'] ); } public function getTimestamp() { return $this->format( 'U' ); } } $date = new MyDateTime(); $need_score = 248; $timestamp = 1417763475; $current_score = 0.7; $date_now = new DateTime(); $date = new MyDateTime(); $date->setTimestamp($timestamp); $interval_days = $date_now->diff($date)->days + 1; print ($need_score - $current_score) * $interval_days;
based on afCkP
Output for 5.3.0 - 5.4.44, 5.6.28, 7.0.20 - 7.2.0
67265.6
Output for 7.0.6
127606.8
Output for 7.0.5
119940.5
Output for 7.0.4
114252.6
Output for 7.0.3
116231
Output for 7.0.2
117220.2
Output for 7.0.1
117467.5
Output for 7.0.0
118209.4
Output for 5.6.21
127359.5
Output for 5.6.20
121671.6
Output for 5.6.19
113510.7
Output for 5.6.18
115241.8
Output for 5.6.17
116478.3
Output for 5.6.16
118456.7
Output for 5.6.15
118704
Output for 5.6.14
119693.2
Output for 5.6.13
123155.4
Output for 5.6.12
124144.6
Output for 5.6.11
125133.8
Output for 5.6.10
125628.4
Output for 5.6.9
126123
Output for 5.6.8
126617.6
Output for 5.5.35
132305.5
Output for 5.5.34
121918.9
Output for 5.5.33
113758
Output for 5.5.32
115983.7
Output for 5.5.31
116725.6
Output for 5.5.30
119445.9
Output for 5.5.29
123402.7
Output for 5.5.28
124391.9
Output for 5.5.27
124639.2
Output for 5.5.26
125875.7
Output for 5.5.25
126370.3
Output for 5.5.24
132552.8
Output for 5.4.45
68254.8
Output for 5.2.0 - 5.2.17
Fatal error: Call to undefined method DateTime::diff() in /in/QgCar on line 27
Process exited with code 255.
Output for 5.0.0 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/QgCar on line 3
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/QgCar on line 5
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/QgCar on line 5
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/QgCar on line 5
Process exited with code 255.