eugene2009 Posted February 19, 2010 Share Posted February 19, 2010 $sql = "SELECT *, date_format(date, '%m/%d/%Y at %I:%i %p' )as date FROM comments WHERE tutorialid='1' ORDER BY commentid DESC LIMIT $offset, $rowsperpage"; Can I change the timezone for the date_format? i dont know how.. i need it in PST please help Quote Link to comment https://forums.phpfreaks.com/topic/192604-mysql-timezone/ Share on other sites More sharing options...
PFMaBiSmAd Posted February 19, 2010 Share Posted February 19, 2010 The mysql documentation contains a section on setting the time zone that is used by mysql - http://dev.mysql.com/doc/refman/5.0/en/time-zone-support.html Depending on your access level to the server, you can set it globally on the server or you can set it per-connection (requires that you execute a query like SET time_zone = timezone before you execute any queries that are time zone specific.) Quote Link to comment https://forums.phpfreaks.com/topic/192604-mysql-timezone/#findComment-1014793 Share on other sites More sharing options...
eugene2009 Posted February 20, 2010 Author Share Posted February 20, 2010 I already read that article but it does not make sense to me because I do not have access to the server.. i tried this $sql = "SELECT *, date_format(date, '%m/%d/%Y at %I:%i %p' )as date FROM comments SET time_zone = America/Los_Angeles WHERE tutorialid='1' ORDER BY commentid DESC LIMIT $offset, $rowsperpage"; this still doesnt work.. please help Quote Link to comment https://forums.phpfreaks.com/topic/192604-mysql-timezone/#findComment-1015144 Share on other sites More sharing options...
Mchl Posted February 20, 2010 Share Posted February 20, 2010 $sql1 = "SET time_zone = 'America/Los_Angeles'"; mysql_query($sql1); $sql2 = "SELECT *, date_format(date, '%m/%d/%Y at %I:%i %p' )as date FROM comments WHERE tutorialid='1' ORDER BY commentid DESC LIMIT $offset, $rowsperpage"; $result = mysql_query($sql2); Quote Link to comment https://forums.phpfreaks.com/topic/192604-mysql-timezone/#findComment-1015210 Share on other sites More sharing options...
eugene2009 Posted February 22, 2010 Author Share Posted February 22, 2010 that does not work.. hmm i tried everything possible somebody PLEASE HELP ME! Quote Link to comment https://forums.phpfreaks.com/topic/192604-mysql-timezone/#findComment-1016004 Share on other sites More sharing options...
Rustywolf Posted February 22, 2010 Share Posted February 22, 2010 date_default_timezone_set('America/Los_Angeles'); $date_format = date("m/d/Y") . " at " . date("I:i") . " " . date("p"); $sql2 = "SELECT *, $date_format as date FROM comments WHERE tutorialid='1' ORDER BY commentid DESC LIMIT $offset, $rowsperpage"; $result = mysql_query($sql2); See if that works Quote Link to comment https://forums.phpfreaks.com/topic/192604-mysql-timezone/#findComment-1016020 Share on other sites More sharing options...
Mchl Posted February 22, 2010 Share Posted February 22, 2010 date_default_timezone_set('America/Los_Angeles'); $date_format = date("m/d/Y") . " at " . date("I:i") . " " . date("p"); $sql2 = "SELECT *, $date_format as date FROM comments WHERE tutorialid='1' ORDER BY commentid DESC LIMIT $offset, $rowsperpage"; $result = mysql_query($sql2); See if that works ROTFL Quote Link to comment https://forums.phpfreaks.com/topic/192604-mysql-timezone/#findComment-1016030 Share on other sites More sharing options...
eugene2009 Posted February 23, 2010 Author Share Posted February 23, 2010 seriously.. come on. just help me Quote Link to comment https://forums.phpfreaks.com/topic/192604-mysql-timezone/#findComment-1016538 Share on other sites More sharing options...
Mchl Posted February 23, 2010 Share Posted February 23, 2010 If all else fails, you can try substracting time difference between PST and server's time zone Quote Link to comment https://forums.phpfreaks.com/topic/192604-mysql-timezone/#findComment-1016658 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.