Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Local time

Status
Not open for further replies.

EvertonFC

Technical User
Nov 24, 2004
107
GB
Hello

In the following:

$city["Name"] = "Wherever";
echo gmdate("H:i"); //echo the formatted date
echo " hours in the wonderful city of ".$city["Name"];

I am getting the time as an hour ahead of what i really is: if it's 2pm here, it shows 3pm.

Is there a way to resolve this. Also, if possible, I would prefer the 11pm type of clock (not 2300), with the letters am and pm after the figures.

Any assistance or links would be appreciated.

Thanks

EvertonFC
 
EvertonFC, I don't even know you, but I can tell you that you are in either the U.K. or France.

I know this because gmdate() is providing a time only one hour off your local time. gmdate() provides times/dates in Greenwich Mean Time, and if that's only one hour off of your local time, you have to be close to Greenwich.

If you want localtime, I recommend that you use date() instead of gmdate().

If you need a reference on the format string, I recommend that you look at the PHP online manual entry for date():
Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Hello Sleipnir

Thanks for your message.

This is what I have now:

$city["Name"] = "Wherever";
echo date("H:i");
echo " hours in the wonderful city of ".$city["Name"];

but I am still getting an hour ahead.

Yes, I am in the UK. I think Europe is an hour ahead (and more the further east you go), so France/Germany, etc will be an hour ahead of GMT.

But how do I get my clock to show the time in the UK? I have removed the gm as you suggested.

Thanks.

EvertonFC

 
PHP gets its time from the server's clock.

At a start, I would make sure that the time and timezone settings on the server are right. I don't know when your part of Europe goes on and off daylight savings time, but you might check those settings, too.



Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top