kts Posted April 9, 2009 Share Posted April 9, 2009 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! Link to comment https://forums.phpfreaks.com/topic/153364-solved-trying-to-format-date-from-mysql-properly/ Share on other sites More sharing options...
Yesideez Posted April 9, 2009 Share Posted April 9, 2009 echo date('xxxxx',strtotime($sqldate)); Â Check this page for what to replace xxxxx with: Â http://www.php.net/date Link to comment https://forums.phpfreaks.com/topic/153364-solved-trying-to-format-date-from-mysql-properly/#findComment-805750 Share on other sites More sharing options...
nankoweap Posted April 9, 2009 Share Posted April 9, 2009 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 Link to comment https://forums.phpfreaks.com/topic/153364-solved-trying-to-format-date-from-mysql-properly/#findComment-805751 Share on other sites More sharing options...
kts Posted April 9, 2009 Author Share Posted April 9, 2009 Awesome, combination of the two nailed it. Thanks! Link to comment https://forums.phpfreaks.com/topic/153364-solved-trying-to-format-date-from-mysql-properly/#findComment-805767 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.