c# Ajay Bharadwaj KN
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.
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(); |
Does anyone have any suggestions where to look or what to do to fix this problem?
While playing around with the great MySQL Activity Reporter , I ran into the following error.
[client 192.168.254.72] PHP Fatal error: strftime() [function.strftime]: Timezone database is corrupt - this should *never* happen! in /var/lib/mysqlard/mysqlar.php on line 62
Now the error is clear .. the Timezone database is corrupt and I`m the one to blame for .. this was on a pretty stripped down Centos that lives in UTC. So there wasn't a real Timezone database.
Obviously a quick apt-get install tzdata solved the problem, but once again the lesson is.. don't strip too much .. you'll eventually endup needing those 3 Kb of free space you gained anyhow.