note 52244 added to function.time
| From: | petar74 at hotmail dot com | Date: | Tue, 26 Apr 2005 04:00:43 +0000 |
| Subject: | note 52244 added to function.time | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-88543@lists.php.net to get a copy of this message | ||
I am new to php so if you have any comments send it pls.
I needed users time ,time on his PC and what ever I found online it was some case where user was
asked for time zone trought some form aaand that was ugly to me so I make this solution wich is
working .. I belive .
first part was in javascript.. I needed users time zone offset (but I dont wish user to tipe or
klick anything) so I add to my page somethign like this
var now = new Date();
var tzo = now.getTimezoneOffset(); // time zone ofset
var lnk='tmz.php?gmt='+ tzo ; //make it part of a link
window.location=lnk; // and relocate and pass it
and then simple calculation
<?php
if ($gmt < 0 ) // time zone offset can be - or +
{
$time=time()-($gmt*60); // if it is -
}
else
{
$time=time()+($gmt*60) ; // if is +
}
$user_time=gmdate('g:i a', $time); // and here we are this is user time
print $user_time ;
?>
I hope this will help some one :)
----
Manual Page -- http://www.php.net/manual/en/function.time.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+52244
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+52244&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+52244&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+52244&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+52244&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+52244&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+52244&report=yes
Search -- http://master.php.net/manage/user-notes.php