Jump to content

[SOLVED] Trying to format date from mysql properly


kts

Recommended Posts

Ok so here is the issue. The server is westcoast and I need the time to be EST.

 

2009-04-05 22:03:55

 

is the output I get. So what I want to do is adjust it (change hour to +3) and then spit it back out in a more user friendly text version.

 

I have tried strtotime(), doesn't seem to be what I want, plus I am unsure the safest best route for changing the time then re-displaying it properly.

 

Thanks!

easiest way is to let mysql do it by using the date_add function. should be something like:

 

select date_add(datetime_column, interval 3 hour)
  from some_table ...

 

and if you store each user's gmt offset or calculate the user's gmt offset, you could easily tailor the query. first convert it to gmt and then adjust according to the user's profile.

 

jason

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.