Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-29-2005, 08:26 PM   PM User | #1
Bry Man
Regular Coder

 
Join Date: Sep 2002
Location: California
Posts: 511
Thanks: 1
Thanked 1 Time in 1 Post
Bry Man is an unknown quantity at this point
Can you format php's date() to use a timezone?

Hey

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.
__________________
When traveling down the road of life, Try not to drag your face in the gravel.

Last edited by Bry Man; 06-30-2005 at 02:15 AM..
Bry Man is offline   Reply With Quote
Old 06-29-2005, 10:27 PM   PM User | #2
chump2877
Senior Coder

 
chump2877's Avatar
 
Join Date: Dec 2004
Location: the U.S. of freakin' A.
Posts: 2,530
Thanks: 15
Thanked 128 Times in 121 Posts
chump2877 is on a distinguished road
just find out what the servers time zone is and add or subtract to obtain the right figure?
__________________
Regards, R.J.
chump2877 is offline   Reply With Quote
Old 06-29-2005, 10:30 PM   PM User | #3
Bry Man
Regular Coder

 
Join Date: Sep 2002
Location: California
Posts: 511
Thanks: 1
Thanked 1 Time in 1 Post
Bry Man is an unknown quantity at this point
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.
__________________
When traveling down the road of life, Try not to drag your face in the gravel.
Bry Man is offline   Reply With Quote
Old 06-30-2005, 01:31 AM   PM User | #4
chump2877
Senior Coder

 
chump2877's Avatar
 
Join Date: Dec 2004
Location: the U.S. of freakin' A.
Posts: 2,530
Thanks: 15
Thanked 128 Times in 121 Posts
chump2877 is on a distinguished road
Try this:

PHP Code:
$hour_difference "7";

$timeadjust = ($hour_difference 60 60);

$local_timestamp date("l, d F Y h:i a",time() - $timeadjust);

print (
"$local_timestamp"); 

your hour difference from the server is -7, which is why you are subtracting $timeadjust from time(), instead of adding it....
__________________
Regards, R.J.
chump2877 is offline   Reply With Quote
Old 06-30-2005, 02:20 AM   PM User | #5
Bry Man
Regular Coder

 
Join Date: Sep 2002
Location: California
Posts: 511
Thanks: 1
Thanked 1 Time in 1 Post
Bry Man is an unknown quantity at this point
Thanks for the help, that works great
__________________
When traveling down the road of life, Try not to drag your face in the gravel.
Bry Man is offline   Reply With Quote
Old 06-30-2005, 02:34 AM   PM User | #6
chump2877
Senior Coder

 
chump2877's Avatar
 
Join Date: Dec 2004
Location: the U.S. of freakin' A.
Posts: 2,530
Thanks: 15
Thanked 128 Times in 121 Posts
chump2877 is on a distinguished road
you're welcome...
__________________
Regards, R.J.
chump2877 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:55 PM.


Advertisement
Log in to turn off these ads.