hassank1 Posted April 12, 2008 Share Posted April 12, 2008 the date/time saved in my database depends on the server time zone .. how can I when I fetch the saved Date from my DB to convert it to a different timezone before "echo" it .. Link to comment https://forums.phpfreaks.com/topic/100835-changing-time-zone/ Share on other sites More sharing options...
amites Posted April 12, 2008 Share Posted April 12, 2008 couple ways, 1 set the timezone (assuming PHP 5) - see http://us3.php.net/manual/en/function.time.php for instructions 2: create a function to alter the time before being displayed to sync up with the timezone you want to use, which can be scaled into a user selectable timezone 3: adjust the time before putting into your DB, which means not using now() statements but now() + INTERVAL X HOURS or something along those lines hope this helps Link to comment https://forums.phpfreaks.com/topic/100835-changing-time-zone/#findComment-515633 Share on other sites More sharing options...
hassank1 Posted April 12, 2008 Author Share Posted April 12, 2008 Ok thx .. I'll check them out .. what about the date that's already been saved according to the server time.. is there a SQL query to alter the date fields so the date will increase an X number of hours ? Link to comment https://forums.phpfreaks.com/topic/100835-changing-time-zone/#findComment-515638 Share on other sites More sharing options...
amites Posted April 14, 2008 Share Posted April 14, 2008 something along the lines of UPDATE table SET field = field + INTERVAL X HOUR Link to comment https://forums.phpfreaks.com/topic/100835-changing-time-zone/#findComment-516494 Share on other sites More sharing options...
hassank1 Posted April 14, 2008 Author Share Posted April 14, 2008 something along the lines of UPDATE table SET field = field + INTERVAL X HOUR if the date will increment let's say 1 day after adding X hours .. the mysql engine will handle that automatically right ? Link to comment https://forums.phpfreaks.com/topic/100835-changing-time-zone/#findComment-516576 Share on other sites More sharing options...
amites Posted April 15, 2008 Share Posted April 15, 2008 yup, mySQL is smart Link to comment https://forums.phpfreaks.com/topic/100835-changing-time-zone/#findComment-518013 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.