View Full Version : Can you format php's date() to use a timezone?
06-29-2005, 09:26 PM
I was wondering if it were possible to format php's date() function to display in a specific time zone, mine which is -07:00, and not the servers which is +02:00. Is this possible? I *thought* it was something like O-07:00 but O only displays ther servers timezone...any help is appreciated.
06-29-2005, 11:27 PM
just find out what the servers time zone is and add or subtract to obtain the right figure?
06-29-2005, 11:30 PM
How would you go about doing that? I didnt think that you could subtract or add time to the servers time, thats what I thought that O -07:00 would do. Im using it as part of a user logging script that...logs users, and the time is kinda important. Im sorry but im not well versed in some areas of php, simple and complex as they may be. Could you perhaps provide an example please? Thanks for the reply though.
06-30-2005, 02:31 AM
$hour_difference = "7";
$timeadjust = ($hour_difference * 60 * 60);
$local_timestamp = date("l, d F Y h:i a",time() - $timeadjust);
your hour difference from the server is -7, which is why you are subtracting $timeadjust from time(), instead of adding it....
06-30-2005, 03:20 AM
Thanks for the help, that works great :thumbsup:
06-30-2005, 03:34 AM
you're welcome... ;)
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.