newbtophp Posted August 12, 2010 Share Posted August 12, 2010 I have an idea, which I'm trying to realise, im using the time() function to store the timestamp within my db...and within the db I have a timezone column (which contains the timezone selected by that user). So I'd like to display $row['timestamp'] (the stored timestamp generated by time()) to the specified timezone, how would that work? <?php //$timestamp = timestamp generated by the time() function //$timezone = the timezone to convert $timestamp too function convert_time($timestamp, $timezone) { //$new_timestamp = do something to adapt $timestamp to $timezone //return the formatted/readable date... return date('D M Y H:i', $new_timestamp); } ?> Link to comment https://forums.phpfreaks.com/topic/210516-format-timestamp-to-timezone/ Share on other sites More sharing options...
PFMaBiSmAd Posted August 12, 2010 Share Posted August 12, 2010 Too bad you didn't store the time using a DATETIME or mysql TIMESTAMP, because you can do this directly in your query using the mysql CONVERT_TZ() function - CONVERT_TZ('2004-01-01 12:00:00','GMT','MET'); You could probably use the mysql FROM_UNIXTIME() function to get your data into a format that would work. Link to comment https://forums.phpfreaks.com/topic/210516-format-timestamp-to-timezone/#findComment-1098390 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.