note 28743 added to function.date

From: Date: Wed, 22 Jan 2003 19:40:41 +0000
Subject: note 28743 added to function.date
Groups: php.notes 
Request: Send a blank email to php-notes+get-42607@lists.php.net to get a copy of this message
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. -- http://www.php.net/manual/en/function.date.php http://master.php.net/manage/user-notes.php?action=edit+28743 http://master.php.net/manage/user-notes.php?action=delete+28743 http://master.php.net/manage/user-notes.php?action=reject+28743

« previous php.notes (#42607) next »