date code not working correctly

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
ericburnard
Forum Contributor
Posts: 104
Joined: Wed Jun 15, 2005 5:11 pm
Location: Chesterfield, UK

date code not working correctly

Post by ericburnard »

i am using this code

Code: Select all

date('d/m/Y :: [G]');
for my date and time and instead of getting the correct time i am getting one 8 hours earlier.
What can i do to make it show thie time on my computer.

(my site is http://www.madashatters.com is you want to look at the date on the blog entry. it was actually posted at 6.12 pm)

thanks
Eric
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

Sounds like the date on your server is different than your local time.
User avatar
ericburnard
Forum Contributor
Posts: 104
Joined: Wed Jun 15, 2005 5:11 pm
Location: Chesterfield, UK

Post by ericburnard »

how can i change thAT to my time? can i?

eric

[EDIT] its not my server im hosted on ipowerweb
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

Code: Select all

date('d/m/Y :: [G]',strtotime("+ 8 hours"));
User avatar
ericburnard
Forum Contributor
Posts: 104
Joined: Wed Jun 15, 2005 5:11 pm
Location: Chesterfield, UK

Post by ericburnard »

ahhhh thank you very much :)
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

I would create a function or even better a constant value for the date difference.

This way you only have one place to change the date offset incase you change servers...
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

what you should do is create a "preferences" section so users can set their own time (zone) and have it calculate their local time automatically.
User avatar
ericburnard
Forum Contributor
Posts: 104
Joined: Wed Jun 15, 2005 5:11 pm
Location: Chesterfield, UK

Post by ericburnard »

well at the moment im just trying to get my site up an running but when thats done i wthink ill do the preferences thing to put in with my admin section etc.

Thanks again
Eric
Post Reply