Jump to content

MySql timezone


eugene2009

Recommended Posts

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.)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

$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);

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.