PHP Gurus,
        I'm building a calendar which does some things like compare
dates. For example, if an event is in the past, then the link in the
calendar is made inactive. To do this I'm converting everything into
UNIX time stamps, so I can do simple "greater than" or "less than" type
equations to figure out which dates come in what order.
        Here's how I've got it set up:
        $currentMonth and $currentYear are the month and year that the
user has selected to look at. $dayCount is where I'm storing the date. I
build the calendar table by using a loop to put in the right date in
$dayCount and then echo it out in each table cell to draw a months worth
of dates.
        So, to compare dates, I take these variables and make it into a
unix timestamp:
        $dateFromPHP = mktime(' ',' ',' ',$currentMonth, $dayCount,
$currentYear);
        Then, I get all the relevant event dates for that month from
MySQL, like so:
        $query = "SELECT UNIX_TIMESTAMP(eventdate) FROM table WHERE
MONTH(eventdate) = " . $currentMonth;
        I put the results into an array called $dateFromMySQL.
        Okay, now here's where it gets wonky. If both PHP and MySQL are
set to default time zone settings, then this following command will
return some results:
        if (in_array($dateFromPHP, $dateFromMySQL)
        I use the results to determine if in any one table cell I need
to do some handling of events. If there are no matches in the array,
then I just echo out the date. As I say, this works fine when I don't
try to adjust time zones.
        But, if at the top of my PHP script I declare the time zone as
being in Japan, like so:
        putenv("TZ=Japan");
        Then the in_array command never returns anything anymore.
        I don't understand why this happens. Since I don't specify the
hours, minutes, or seconds, the time zone difference shouldn't apply.
        I thought maybe MySQL needed to be set to have the same time
zone as the PHP script, but, according to my web hosting service, that
is impossible to set for just my site without affecting all the other
sites on the same server.
        So I need to compensate for different time zones between my
script and my MySQL server. But I can't figure out how to do that since
I don't know why there is a difference in the first place.
        Any help would be much appreciated.

-- 
Cheers!
Dave G
[EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to