[PHP] Managing time zones
Among other user preferences, I need to record their time zone, so that timestamps retrieved from a database can be displayed in their local time. There are all sorts of schemes for this, providing varying levels of detail (for a lot of detail, have a look in /usr/share/zoneinfo!). I would probably be willing to sacrifice subtle city-by-city idiosyncracies in exchange for simplicity as long as I were still able to handle daylight savings time for major populated areas. Recording +0400, for instance, is not good enough. Has anyone worked with this in the context of PHP? Any good pointers or inspiration? Thanks. miguel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Managing time zones
Hi One method is to use javascript to get the clients date/time then create a diff between that and your time and use it to change the display times. Here is a demo of getting the remote date and time pre html head titleUntitled/title ?if(!isset($Submit)):? script language=JavaScript !-- begin function gogo() { var dt = new Date(); var mm,dd,yy,h,m,s; mm = dt.getMonth()+1; dd = dt.getDate(); yy = dt.getYear(); h = dt.getHours(); m = dt.getMinutes(); s = dt.getSeconds(); document.location=?echo $PHP_SELF??Time=+h+:+m+:+s+Submit=yesMonth=+mm+Day=+dd+Year=+yy } // end -- /script ?endif? /head body?if(!isset($Submit)):? onload=gogo()?endif? ? if(isset($Submit)): echo Remote date = $Month/$Day/$Year $Time br; endif; ? /body /html /pre Tom At 10:38 AM 4/04/2002, Miguel Cruz wrote: Among other user preferences, I need to record their time zone, so that timestamps retrieved from a database can be displayed in their local time. There are all sorts of schemes for this, providing varying levels of detail (for a lot of detail, have a look in /usr/share/zoneinfo!). I would probably be willing to sacrifice subtle city-by-city idiosyncracies in exchange for simplicity as long as I were still able to handle daylight savings time for major populated areas. Recording +0400, for instance, is not good enough. Has anyone worked with this in the context of PHP? Any good pointers or inspiration? Thanks. miguel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Managing time zones
Hi This time without the html ... sorry :) One method is to use javascript to get the clients date/time then create a diff between that and your time and use it to change the display times. Here is a demo of getting the remote date and time head titleUntitled/title ?if(!isset($Submit)):? script language=JavaScript !-- begin function gogo() { var dt = new Date(); var mm,dd,yy,h,m,s; mm = dt.getMonth()+1; dd = dt.getDate(); yy = dt.getYear(); h = dt.getHours(); m = dt.getMinutes(); s = dt.getSeconds(); document.location=?echo $PHP_SELF??Time=+h+:+m+:+s+Submit=yesMonth=+mm+Day=+dd+Year=+yy } // end -- /script ?endif? /head body?if(!isset($Submit)):? onload=gogo()?endif? ? if(isset($Submit)): echo Remote date = $Month/$Day/$Year $Time br; endif; ? /body Tom At 10:38 AM 4/04/2002, Miguel Cruz wrote: Among other user preferences, I need to record their time zone, so that timestamps retrieved from a database can be displayed in their local time. There are all sorts of schemes for this, providing varying levels of detail (for a lot of detail, have a look in /usr/share/zoneinfo!). I would probably be willing to sacrifice subtle city-by-city idiosyncracies in exchange for simplicity as long as I were still able to handle daylight savings time for major populated areas. Recording +0400, for instance, is not good enough. Has anyone worked with this in the context of PHP? Any good pointers or inspiration? Thanks. miguel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php