@ 2018-06-22T05:24:44Z <?php
$period = getPeriod('2018-08-21 23:59:59.999999', '2018-08-22 00:00:00.000000');
print_r($period);
function getPeriod($date1 = null, $date2 = null) {
try {
$dt_date1 = new \DateTime($date1);
$dt_date2 = new \DateTime($date2);
$diff = $dt_date2->diff($dt_date1);
// Workaround für PHP Bug #75855
if ($diff->format('%f') < 0) {
$diff->s--;
//$diff->f++; // = $diff->f + 1; // = number_format($diff->f+1, 6, '.', '');
$diff->f = $diff->f + 1; // = number_format($diff->f+1, 6, '.', '');
}
return $diff;
} catch (\Exception $e) {
$exceptionHanlder = new ExceptionHandler($e);
}
}
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 8.2.0 - 8.2.18 , 8.3.0 - 8.3.4 , 8.3.6 DateInterval Object
(
[y] => 0
[m] => 0
[d] => 0
[h] => 0
[i] => 0
[s] => 0
[f] => 1.0E-6
[invert] => 1
[days] => 0
[from_string] =>
)
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
DateInterval Object
(
[y] => 0
[m] => 0
[d] => 0
[h] => 0
[i] => 0
[s] => 0
[f] => 1.0E-6
[invert] => 1
[days] => 0
[from_string] =>
)
Output for 7.2.0 - 7.2.33 , 7.3.0 - 7.3.33 , 7.4.0 - 7.4.33 , 8.0.0 - 8.0.30 , 8.1.0 - 8.1.28 DateInterval Object
(
[y] => 0
[m] => 0
[d] => 0
[h] => 0
[i] => 0
[s] => 0
[f] => 1.0E-6
[weekday] => 0
[weekday_behavior] => 0
[first_last_day_of] => 0
[invert] => 1
[days] => 0
[special_type] => 0
[special_amount] => 0
[have_weekday_relative] => 0
[have_special_relative] => 0
)
Output for 7.1.0 - 7.1.33 DateInterval Object
(
[y] => 0
[m] => 0
[d] => 0
[h] => 0
[i] => 0
[s] => 0
[f] => 1.0000000000288E-6
[weekday] => 0
[weekday_behavior] => 0
[first_last_day_of] => 0
[invert] => 1
[days] => 0
[special_type] => 0
[special_amount] => 0
[have_weekday_relative] => 0
[have_special_relative] => 0
)
Output for 5.3.27 - 5.3.29 , 5.4.17 - 5.4.45 , 5.5.0 - 5.5.38 , 5.6.0 - 5.6.30 , 7.0.0 - 7.0.30 DateInterval Object
(
[y] => 0
[m] => 0
[d] => 0
[h] => 0
[i] => 0
[s] => 1
[weekday] => 0
[weekday_behavior] => 0
[first_last_day_of] => 0
[invert] => 1
[days] => 0
[special_type] => 0
[special_amount] => 0
[have_weekday_relative] => 0
[have_special_relative] => 0
)
Output for 5.3.0 - 5.3.26 , 5.4.0 - 5.4.16 DateInterval Object
(
[y] => 0
[m] => 0
[d] => 0
[h] => 0
[i] => 0
[s] => 1
[invert] => 1
[days] => 0
)
Output for 5.2.0 - 5.2.17 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/JJivD on line 9
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/JJivD on line 10
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/JJivD on line 22
Fatal error: Call to undefined method DateTime::diff() in /in/JJivD on line 11
Process exited with code 255 . Output for 5.0.0 - 5.0.5 , 5.1.0 - 5.1.6 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/JJivD on line 9
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/JJivD on line 10
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/JJivD on line 22
Fatal error: Class 'DateTime' not found in /in/JJivD on line 9
Process exited with code 255 . Output for 4.4.2 - 4.4.9 Parse error: syntax error, unexpected '{' in /in/JJivD on line 8
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 '{' in /in/JJivD on line 8
Process exited with code 255 . Output for 4.3.2 - 4.3.4 Parse error: parse error in /in/JJivD on line 8
Process exited with code 255 . preferences:dark mode live preview
292.91 ms | 401 KiB | 420 Q