note 31795 deleted from function.mktime by sniper
| From: | sniper@php.net | Date: | Tue, 04 Nov 2003 13:10:36 +0000 |
| Subject: | note 31795 deleted from function.mktime by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-59871@lists.php.net to get a copy of this message | ||
Note Submitter: grimtraffic@numep.ru
----
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
*******************************/