Jump to content

convert date from US to UK from a string got from mysql


newbeee

Recommended Posts

i tried the following code but this seems to return the current date and time.

 

the format i use in mysql is 0000-00-00 00:00:00

and would like to convert to this format...

dd-mm-yyy hh:mm:ss

 

echo gmdate("d M Y H:i", time($rows['created_on']));

 

can someone please help me out

this is more likely the way i need to do it as i can not change the 'create_on' string as it is used later on in the script.

 

but using this method you say did not work it seem to mess up the date and time to a random date and time.

 

i am using mysql datetime as a default so it is stored in US format, when i get the data from the DB in to the string i need to have it converted to the GMT format.

 

You probably want to do this:

 

echo gmdate("d M Y H:i", strtotime($rows['created_on']));

what timezone is the UK and what timezone in the US are you trying to do..

 

if lets say UK is +0 GMT and you want the US timestamp to be -5GMT just do..

 

strtotime($rows['created_on']." -5 hours");

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.