When I want to calculate a difference in days (using date1 and date2 as an example):
$date1 = '2019-03-27';
$date2 = '2019-04-01';
echo((strtotime($date2) - strtotime($date1)) / 86400);
The result is:
2
However doing the same with:
$date1 = '2019-03-27';
$date2 = '2019-04-01';
echo((strtotime($date2) - strtotime($date1)) / 86400);
Returns:
4.9583333333333
This could be fixed with: date_default_timezone_set('UTC');.
But why isn't PHP using the same timezones for certain dates by default?