Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to store a datetime in MySQL with timezone info
    primarykey
    data
    text
    <p>I have thousands of photos that were taken in Tanzania and I want to store the date and time each photo was taken in a MySQL database. The server, however, is located in the U.S. and I run into problems when I try to store a Tanzanian date-time that falls within the "invalid" hour during spring Daylight Savings time (in the U.S.). Tanzania doesn't do DST, so the time is an actually valid time. </p> <p>Additional complications are that there are collaborators from many different timezones who will need to access the date-time values stored in the database. I want them to <em>always</em> come out as Tanzanian time and not in the local times that various collaborator are in. </p> <p>I'm reluctant to set session times because I know that there will be problems when someone sometime forgets to set a session time and gets the times out all wrong. And I do not have authority to change anything about the server.</p> <p>I've read: <a href="https://stackoverflow.com/questions/2532729/daylight-saving-time-and-time-zone-best-practices?rq=1">Daylight saving time and time zone best practices</a> and <a href="https://stackoverflow.com/questions/1646171/mysql-datetime-fields-and-daylight-savings-time-how-do-i-reference-the-extra">MySQL datetime fields and daylight savings time -- how do I reference the &quot;extra&quot; hour?</a> and <a href="https://stackoverflow.com/questions/1349280/storing-datetime-as-utc-in-php-mysql">Storing datetime as UTC in PHP/MySQL</a></p> <p>But none of them seems to address my particular problem. I'm not an SQL expert; is there a way to specify timezone when setting DATETIMEs? I haven't seen one. Otherwise, any suggestions on how to approach this issue is greatly appreciated.</p> <p>Edit: Here's an example of the problem I'm running into. I send the command:</p> <pre><code>INSERT INTO Images (CaptureEvent, SequenceNum, PathFilename, TimestampJPG) VALUES (122,1,"S2/B04/B04_R1/IMAG0148.JPG","2011-03-13 02:49:10") </code></pre> <p>And I get the error:</p> <pre><code>Error 1292: Incorrect datetime value: '2011-03-13 02:49:10' for column 'TimestampJPG' </code></pre> <p>This date and time exists in Tanzania, but not in the U.S., where the database is.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload