note 31795 added to function.mktime

From: Date: Sun, 04 May 2003 01:04:36 +0000
Subject: note 31795 added to function.mktime
Groups: php.notes 
Request: Send a blank email to php-notes+get-47482@lists.php.net to get a copy of this message
If you need to record a time on the computer of somone who's for example is leaving a message in your guestbook, you can do this(requires javascript): //HTML part: <pre> <form name="gbo"> name:<include name="name" /><br /> e-mail<include name="email" /><br /> <textarea name="body"></textarea> <include type="hidden" name="offset" /> </form> <script language="JavaScript"> tt=new Date(); document.gbo.offset.value=tt.getTimezoneOffset(); </script> </pre> //php script recieving request: <pre> <?php $off=$offset/60; $date=gmdate("D, d M Y H:i:s", mktime(date("H")-$off)); if($off>0){$off="-0".$off.":00";} if($off<=0){$off="+0".(-$off).":00";} if(intval($offset)!=0){ $date.=" ".$off; if(date("I")){$date.=" Summer Time";}} ?> </pre> /******************************* Now the string $date will have a date such as Sat, 03 May 2003 20:46:02 +04:00 Summer Time or Sun, 04 May 2003 00:46:02 if the time matches GMT, even if it is only because of Daylight Saving Time Hope it helps, the credit is mine McTrafik *******************************/ -- http://www.php.net/manual/en/function.mktime.php http://master.php.net/manage/user-notes.php?action=edit+31795 http://master.php.net/manage/user-notes.php?action=delete+31795 http://master.php.net/manage/user-notes.php?action=reject+31795

« previous php.notes (#47482) next »