Jump to content

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


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");

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.