FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Problems with the PHP date() function





Solugon
I can't seem to figure out how to change what date() comes out with from, say, 9:00 PM to 7:00 PM. It's showing me a time that's two hours ahead of what I want it to show...
hexkid
Solugon wrote:
I can't seem to figure out how to change what date() comes out with from, say, 9:00 PM to 7:00 PM. It's showing me a time that's two hours ahead of what I want it to show...


use gmdate() and adjust according to your GMT offset, for example
Code:
<?php
define('GMT_OFFSET', '-25200'); // for time at GMT-0700
$now = gmdate('Y-m-d H:i:s', time() + GMT_OFFSET);
echo $now, '<br>';
?>


If you have PHP 5 >= 5.1.0RC1 you probably could use the timezone information. See date_default_timezone_set().
Solugon
Thanks a lot!

Hmm. Now any idea how to make a clock that updates itself every second without requiring a page refresh? >_>
Marston
^ Javascript and forms?
Solugon
K, I'll look into that... thanks.
Related topics
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.