note 28743 deleted from function.date by sniper

From: Date: Sat, 11 Oct 2003 16:51:50 +0000
Subject: note 28743 deleted from function.date by sniper
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-58276@lists.php.net to get a copy of this message
Note Submitter: abandonedsoul@msn.com ---- If you would like to save a time in a database and return it later, you may wish to make your scripts time zone compliant. You may do so by using "gmtime" or "gmmktime" to save the current time, and either of the two following functions to return the saved time in the current time zone. ---------- function getltime ($hour="00", $min="00", $sec="00", $month="00", $day="00", $year="2000") { return date("\[ F d, Y \] h:i A", mktime($hour, $min, $sec, $month, $day, $year)+date("Z")); } function getlmktime ($timeStamp) { return date("\[ F d, Y \] h:i A", $timeStamp+date("Z")); } ---------- Thus, by calling either of these functions: print getltime(18, 45, 27, 01, 17, 2003); print getlmktime(1042857927); PHP will output: [ January 17, 2003 ] 10:45 AM I hope this helps anybody who needs to figure out how to work with time zones.

« previous php.notes (#58276) next »