how to ignore DST in MySQL The 2019 Stack Overflow Developer Survey Results Are InMysql...

Am I thawing this London Broil safely?

Why isn't the circumferential light around the M87 black hole's event horizon symmetric?

The difference between dialogue marks

Why not take a picture of a closer black hole?

What could be the right powersource for 15 seconds lifespan disposable giant chainsaw?

Do these rules for Critical Successes and Critical Failures seem fair?

Are spiders unable to hurt humans, especially very small spiders?

Does the shape of a die affect the probability of a number being rolled?

What does Linus Torvalds mean when he says that Git "never ever" tracks a file?

Pokemon Turn Based battle (Python)

Can a flute soloist sit?

Deal with toxic manager when you can't quit

Is three citations per paragraph excessive for undergraduate research paper?

Protecting Dualbooting Windows from dangerous code (like rm -rf)

Where to refill my bottle in India?

How come people say “Would of”?

How can I autofill dates in Excel excluding Sunday?

Why is the maximum length of OpenWrt’s root password 8 characters?

How to manage monthly salary

Why didn't the Event Horizon Telescope team mention Sagittarius A*?

Falsification in Math vs Science

Can you compress metal and what would be the consequences?

Are there incongruent pythagorean triangles with the same perimeter and same area?

What is the most effective way of iterating a std::vector and why?



how to ignore DST in MySQL



The 2019 Stack Overflow Developer Survey Results Are InMysql fulltext boolean ignore phraseHow to make MySQL 5.1 connection ignore kills?How to compare (in MySQL) a DATETIME value to a TIMESTAMP value?Mysql replication and ignore tablesmysql datetime timezone +0000MySQL - Turkey/Istanbul Daylight Saving Time ChangeDoes AT TIME ZONE automatically take care of DST conversion?Is timestamptz preferred when timezone logic is performed by the client?MySQL: How to ignore /etc/mysql/my.cnf for mysqld --initializeMySQL Replication ignore few columns





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







1















We have a database with flights, and in there, departureTime DATETIME field.



Extra info:



global.time_zone: Europe/Dublin
session.time_zone: Europe/Dublin
MySQL version: 5.7


Problem is, I need to save a flight from China at "2019-03-31 01:00", and server is saving "2019-03-31 02:00" because of the day saving time. In Dublin would be fine, but that flight is from China and should be saved properly.



So what would be the best here?,



Is there any way to ignore DST validations?.



Should I save all datetimes in UTC format and then show them in each timezone?



Should I use timestamp instead of datetime?



If I change server timezone to UTC, what would it happen with old records?










share|improve this question














bumped to the homepage by Community 25 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • datetime manual has a few answers. In general I'd say a system UTC will be helpful. Setting the session timezone before saving a date related.

    – danblack
    Sep 22 '18 at 8:46


















1















We have a database with flights, and in there, departureTime DATETIME field.



Extra info:



global.time_zone: Europe/Dublin
session.time_zone: Europe/Dublin
MySQL version: 5.7


Problem is, I need to save a flight from China at "2019-03-31 01:00", and server is saving "2019-03-31 02:00" because of the day saving time. In Dublin would be fine, but that flight is from China and should be saved properly.



So what would be the best here?,



Is there any way to ignore DST validations?.



Should I save all datetimes in UTC format and then show them in each timezone?



Should I use timestamp instead of datetime?



If I change server timezone to UTC, what would it happen with old records?










share|improve this question














bumped to the homepage by Community 25 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • datetime manual has a few answers. In general I'd say a system UTC will be helpful. Setting the session timezone before saving a date related.

    – danblack
    Sep 22 '18 at 8:46














1












1








1








We have a database with flights, and in there, departureTime DATETIME field.



Extra info:



global.time_zone: Europe/Dublin
session.time_zone: Europe/Dublin
MySQL version: 5.7


Problem is, I need to save a flight from China at "2019-03-31 01:00", and server is saving "2019-03-31 02:00" because of the day saving time. In Dublin would be fine, but that flight is from China and should be saved properly.



So what would be the best here?,



Is there any way to ignore DST validations?.



Should I save all datetimes in UTC format and then show them in each timezone?



Should I use timestamp instead of datetime?



If I change server timezone to UTC, what would it happen with old records?










share|improve this question














We have a database with flights, and in there, departureTime DATETIME field.



Extra info:



global.time_zone: Europe/Dublin
session.time_zone: Europe/Dublin
MySQL version: 5.7


Problem is, I need to save a flight from China at "2019-03-31 01:00", and server is saving "2019-03-31 02:00" because of the day saving time. In Dublin would be fine, but that flight is from China and should be saved properly.



So what would be the best here?,



Is there any way to ignore DST validations?.



Should I save all datetimes in UTC format and then show them in each timezone?



Should I use timestamp instead of datetime?



If I change server timezone to UTC, what would it happen with old records?







mysql datetime timezone






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Sep 20 '18 at 12:30









CyrusCyrus

61




61





bumped to the homepage by Community 25 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 25 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • datetime manual has a few answers. In general I'd say a system UTC will be helpful. Setting the session timezone before saving a date related.

    – danblack
    Sep 22 '18 at 8:46



















  • datetime manual has a few answers. In general I'd say a system UTC will be helpful. Setting the session timezone before saving a date related.

    – danblack
    Sep 22 '18 at 8:46

















datetime manual has a few answers. In general I'd say a system UTC will be helpful. Setting the session timezone before saving a date related.

– danblack
Sep 22 '18 at 8:46





datetime manual has a few answers. In general I'd say a system UTC will be helpful. Setting the session timezone before saving a date related.

– danblack
Sep 22 '18 at 8:46










1 Answer
1






active

oldest

votes


















0














MySQL does not have a datatype that will receive a local time and timezone. You will need to do one of these:




  • Store both fields and worry about interpreting it later.

  • Use application code to convert the time to UTC based on the given TZ. Then store it in a TIMESTAMP while having the system time set to UTC.


When you store 2019-03-31 01:00 into a DATETIME, 2019-03-31 01:00 is the only thing you will ever get from that column.



When you store something in a TIMESTAMP column, it is converted according to MySQL's tz setting, then stored as UTC. When retrieving, it will be reconverted. If nothing has changed, you will get the same value back.



Between 2am and 3am is tricky because that hour repeats once a year. Beware.



If the flight leaves China at 2019-03-31 01:00 China time, but your system is set for Dublin time, neither DATETIME, nor TIMESTAMP will be useful.



Best to convert to/from UTC in your app, then store UTC in the database.






share|improve this answer
























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "182"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f218149%2fhow-to-ignore-dst-in-mysql%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    MySQL does not have a datatype that will receive a local time and timezone. You will need to do one of these:




    • Store both fields and worry about interpreting it later.

    • Use application code to convert the time to UTC based on the given TZ. Then store it in a TIMESTAMP while having the system time set to UTC.


    When you store 2019-03-31 01:00 into a DATETIME, 2019-03-31 01:00 is the only thing you will ever get from that column.



    When you store something in a TIMESTAMP column, it is converted according to MySQL's tz setting, then stored as UTC. When retrieving, it will be reconverted. If nothing has changed, you will get the same value back.



    Between 2am and 3am is tricky because that hour repeats once a year. Beware.



    If the flight leaves China at 2019-03-31 01:00 China time, but your system is set for Dublin time, neither DATETIME, nor TIMESTAMP will be useful.



    Best to convert to/from UTC in your app, then store UTC in the database.






    share|improve this answer




























      0














      MySQL does not have a datatype that will receive a local time and timezone. You will need to do one of these:




      • Store both fields and worry about interpreting it later.

      • Use application code to convert the time to UTC based on the given TZ. Then store it in a TIMESTAMP while having the system time set to UTC.


      When you store 2019-03-31 01:00 into a DATETIME, 2019-03-31 01:00 is the only thing you will ever get from that column.



      When you store something in a TIMESTAMP column, it is converted according to MySQL's tz setting, then stored as UTC. When retrieving, it will be reconverted. If nothing has changed, you will get the same value back.



      Between 2am and 3am is tricky because that hour repeats once a year. Beware.



      If the flight leaves China at 2019-03-31 01:00 China time, but your system is set for Dublin time, neither DATETIME, nor TIMESTAMP will be useful.



      Best to convert to/from UTC in your app, then store UTC in the database.






      share|improve this answer


























        0












        0








        0







        MySQL does not have a datatype that will receive a local time and timezone. You will need to do one of these:




        • Store both fields and worry about interpreting it later.

        • Use application code to convert the time to UTC based on the given TZ. Then store it in a TIMESTAMP while having the system time set to UTC.


        When you store 2019-03-31 01:00 into a DATETIME, 2019-03-31 01:00 is the only thing you will ever get from that column.



        When you store something in a TIMESTAMP column, it is converted according to MySQL's tz setting, then stored as UTC. When retrieving, it will be reconverted. If nothing has changed, you will get the same value back.



        Between 2am and 3am is tricky because that hour repeats once a year. Beware.



        If the flight leaves China at 2019-03-31 01:00 China time, but your system is set for Dublin time, neither DATETIME, nor TIMESTAMP will be useful.



        Best to convert to/from UTC in your app, then store UTC in the database.






        share|improve this answer













        MySQL does not have a datatype that will receive a local time and timezone. You will need to do one of these:




        • Store both fields and worry about interpreting it later.

        • Use application code to convert the time to UTC based on the given TZ. Then store it in a TIMESTAMP while having the system time set to UTC.


        When you store 2019-03-31 01:00 into a DATETIME, 2019-03-31 01:00 is the only thing you will ever get from that column.



        When you store something in a TIMESTAMP column, it is converted according to MySQL's tz setting, then stored as UTC. When retrieving, it will be reconverted. If nothing has changed, you will get the same value back.



        Between 2am and 3am is tricky because that hour repeats once a year. Beware.



        If the flight leaves China at 2019-03-31 01:00 China time, but your system is set for Dublin time, neither DATETIME, nor TIMESTAMP will be useful.



        Best to convert to/from UTC in your app, then store UTC in the database.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Oct 8 '18 at 22:24









        Rick JamesRick James

        43.8k22259




        43.8k22259






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Database Administrators Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f218149%2fhow-to-ignore-dst-in-mysql%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Anexo:Material bélico de la Fuerza Aérea de Chile Índice Aeronaves Defensa...

            Always On Availability groups resolving state after failover - Remote harden of transaction...

            update json value to null Announcing the arrival of Valued Associate #679: Cesar Manara ...