Background Knowledge
I’m trying to determine the difference in minutes between two timestamps. I’m using Pear::Date to do this. The issue comes into play when I noticed that the wrong timezone was being used by Pear::Date, UTC. If I do not use Pear::Date the timezone is set correctly.
I have tried using date_default_timezone_set() and it does set the timezone back, however I feel this shouldn’t be necessary as the default timezone should be used. I have been using date_default_timezone_get() to determine what timezone is being used.
It’s my understanding that Pear::Date uses UTC when it is unable to determine the default timezone. As far as I know I have the default timezone set correctly and with a valid ID (see below). I was able to determine that the timezone changed from my default timezone to UTC after I used Date::setFromDateDiff(). This does not seem right at all.
I have checked the following.
- Pear v1.7.2 stable
- Pear::Date v1.4.7 stable
- php.ini (default timezone) - date.timezone = “Canada/Saskatchewan”
- phpinfo() - Correct configure file being loaded, /var/www/conf/php.ini.
- phpinfo() - Under Date, date/time support is enabled.
- phpinfo() - Default timezone - Canada/Saskatchewan
- phpinfo() - date.timezone - Canada/Saskatchewan / Canada/Saskatchewan
PHP Code Test Case
1
2
3
4
5
6
7
8
9
| require_once("Date.php");
$obFirstDate = new Date('20081014155640');
$obSecondDate = new Date(date("YmdHis",time()));
$obDateSpan = new Date_Span();
$obDateSpan->setFromDateDiff($obFirstDate, $obSecondDate);
echo (int)$obDateSpan->toMinutes();
echo "<br />".date_default_timezone_get(); |
Solution - Unknown
Does anyone have any suggestions where to look or what to do to fix this problem?