3v4l.org

run code in 300+ PHP versions simultaneously
<?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;
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
Deprecated: Return type of MyDateTime::setTimestamp($timestamp) should either be compatible with DateTime::setTimestamp(int $timestamp): DateTime, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/QgCar on line 5 Deprecated: Return type of MyDateTime::getTimestamp() should either be compatible with DateTime::getTimestamp(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/QgCar on line 12 67265.6
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Deprecated: Return type of MyDateTime::setTimestamp($timestamp) should either be compatible with DateTime::setTimestamp(int $timestamp): DateTime, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/QgCar on line 5 Deprecated: Return type of MyDateTime::getTimestamp() should either be compatible with DateTime::getTimestamp(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/QgCar on line 12 67265.6
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.44, 5.6.28, 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30
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.0.5, 5.1.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.3.11, 4.4.0 - 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.

preferences:
256.02 ms | 401 KiB | 311 Q