note 52244 deleted from function.time by aidan

From: Date: Sat, 08 Oct 2005 01:03:17 +0000
Subject: note 52244 deleted from function.time by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-96603@lists.php.net to get a copy of this message
Note Submitter: petar74 at hotmail dot com ---- 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 :)

« previous php.notes (#96603) next »