Jump to content

[SOLVED] This may stump some people... timestamp GMT


NoDoze

Recommended Posts

ok, I have a mysql server that has a few databases on it. The server is running on local time (PST), and I need it to be on local time for the databases. However I have one database that needs to have it's timestamp on GMT.

 

Is there a way to make the timestamp for that one DB to be GMT? Currently I have it set to 'on update current_timestamp' and 'current_timestamp'. So it's timestamping when the data is imported.

 

This data is uploading via a URL in this format:

$uweather = "http://domain.com/update.php?ID=username&PASSWORD=password&dateutc=" . $row['timestamp'] . "&tempf=" . $row['airt_f_avg'] . "&winddir=" . $row['winddir'] . "&windspeedmph=" . $row['ws_mph'] . "&windgustmph=" . $row['ws_max'] . "&rainin=" . $row['rain_in_tot'] . "&baromin=" . $row['baro'] . "&dewptf=" . $row['dewpt_f_avg'] . "&humidity=" . $row['rh_avg'] . "&weather=&clouds=&softwaretype=vws%20versionxx&action=updateraw&realtime=1&rtfreq=2.5";

Is there a way I could change the...

$row['timestamp']

...to be reformatted into GMT?

 

 

Hope that makes sense and someone could help me....

Thanks.

um...unix timestamps don't have timezone info associated with them. to convert between timezones in mysql though, use this function:

http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_convert-tz

just convert it when selecting

You can set or change the time zone for any/each connection -

 

Per-connection time zones. Each client that connects has its own time zone setting, given by the session time_zone variable. Initially, the session variable takes its value from the global time_zone variable, but the client can change its own time zone with this statement:

 

mysql> SET time_zone = timezone;

 

 

no...like this:

 

$data = mysql_fetch_array(mysql_query("SELECT NOW()"));
print "Server time (EST) is: {$data[0]}<br />";
mysql_query("SET time_zone = '+0:00'") or die(mysql_error());
$data = mysql_fetch_array(mysql_query("SELECT NOW()"));
print "GMT time is: {$data[0]}<br />";

Server time (EST) is: 2009-01-21 15:19:25
GMT time is: 2009-01-21 20:19:25

Archived

This topic is now archived and is closed to further replies.

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