24 hour time modulo

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I'm trying to work out what time it will be from midnight (00:00) and noon (12:00) given the time difference between an origin and destination of travel.



If the destination is, say, 5 hours ahead of the origin, then I could use the method found at this Math Stackexchange page:
Calculating time using modulus



So for finding time at origin when it is midnight at destination, I would do $(5+00:00) mod 24$ to get $17:00$, or $5$pm.



But how would I do this for negative time difference?



For example, the time difference between Paris (origin) and Dhaka (destination) is $-04:00$ hours.



If I want Paris time when it's midnight in Dhaka, I'll do $(-4+00:00) mod 24$, but I'll get the negative value of $-4$, but the answer should be $20:00$ ($8$pm).







share|cite|improve this question















  • 4




    Just add $24$ and adjust the date.
    – Math Lover
    Jul 31 at 20:40















up vote
0
down vote

favorite












I'm trying to work out what time it will be from midnight (00:00) and noon (12:00) given the time difference between an origin and destination of travel.



If the destination is, say, 5 hours ahead of the origin, then I could use the method found at this Math Stackexchange page:
Calculating time using modulus



So for finding time at origin when it is midnight at destination, I would do $(5+00:00) mod 24$ to get $17:00$, or $5$pm.



But how would I do this for negative time difference?



For example, the time difference between Paris (origin) and Dhaka (destination) is $-04:00$ hours.



If I want Paris time when it's midnight in Dhaka, I'll do $(-4+00:00) mod 24$, but I'll get the negative value of $-4$, but the answer should be $20:00$ ($8$pm).







share|cite|improve this question















  • 4




    Just add $24$ and adjust the date.
    – Math Lover
    Jul 31 at 20:40













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I'm trying to work out what time it will be from midnight (00:00) and noon (12:00) given the time difference between an origin and destination of travel.



If the destination is, say, 5 hours ahead of the origin, then I could use the method found at this Math Stackexchange page:
Calculating time using modulus



So for finding time at origin when it is midnight at destination, I would do $(5+00:00) mod 24$ to get $17:00$, or $5$pm.



But how would I do this for negative time difference?



For example, the time difference between Paris (origin) and Dhaka (destination) is $-04:00$ hours.



If I want Paris time when it's midnight in Dhaka, I'll do $(-4+00:00) mod 24$, but I'll get the negative value of $-4$, but the answer should be $20:00$ ($8$pm).







share|cite|improve this question











I'm trying to work out what time it will be from midnight (00:00) and noon (12:00) given the time difference between an origin and destination of travel.



If the destination is, say, 5 hours ahead of the origin, then I could use the method found at this Math Stackexchange page:
Calculating time using modulus



So for finding time at origin when it is midnight at destination, I would do $(5+00:00) mod 24$ to get $17:00$, or $5$pm.



But how would I do this for negative time difference?



For example, the time difference between Paris (origin) and Dhaka (destination) is $-04:00$ hours.



If I want Paris time when it's midnight in Dhaka, I'll do $(-4+00:00) mod 24$, but I'll get the negative value of $-4$, but the answer should be $20:00$ ($8$pm).









share|cite|improve this question










share|cite|improve this question




share|cite|improve this question









asked Jul 31 at 20:39









Ansar Al

363




363







  • 4




    Just add $24$ and adjust the date.
    – Math Lover
    Jul 31 at 20:40













  • 4




    Just add $24$ and adjust the date.
    – Math Lover
    Jul 31 at 20:40








4




4




Just add $24$ and adjust the date.
– Math Lover
Jul 31 at 20:40





Just add $24$ and adjust the date.
– Math Lover
Jul 31 at 20:40











1 Answer
1






active

oldest

votes

















up vote
0
down vote



accepted










If you are not keeping track of the date, you can simply use $(24+d+t)$ mod $24$ where $d$ is the time difference and $t$ is the time you are starting with. Your example would become $(24-4+00:00)$ mod $24$, which would be $(20+00:00)$ mod $24$, which would then become $20:00$.



If you are keeping track of the date, you will have to decrement it, as the extra 24 hours added to the time difference will push the date forward one day.






share|cite|improve this answer





















    Your Answer




    StackExchange.ifUsing("editor", function ()
    return StackExchange.using("mathjaxEditing", function ()
    StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
    StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
    );
    );
    , "mathjax-editing");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "69"
    ;
    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',
    convertImagesToLinks: true,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    noCode: true, onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );








     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2868459%2f24-hour-time-modulo%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote



    accepted










    If you are not keeping track of the date, you can simply use $(24+d+t)$ mod $24$ where $d$ is the time difference and $t$ is the time you are starting with. Your example would become $(24-4+00:00)$ mod $24$, which would be $(20+00:00)$ mod $24$, which would then become $20:00$.



    If you are keeping track of the date, you will have to decrement it, as the extra 24 hours added to the time difference will push the date forward one day.






    share|cite|improve this answer

























      up vote
      0
      down vote



      accepted










      If you are not keeping track of the date, you can simply use $(24+d+t)$ mod $24$ where $d$ is the time difference and $t$ is the time you are starting with. Your example would become $(24-4+00:00)$ mod $24$, which would be $(20+00:00)$ mod $24$, which would then become $20:00$.



      If you are keeping track of the date, you will have to decrement it, as the extra 24 hours added to the time difference will push the date forward one day.






      share|cite|improve this answer























        up vote
        0
        down vote



        accepted







        up vote
        0
        down vote



        accepted






        If you are not keeping track of the date, you can simply use $(24+d+t)$ mod $24$ where $d$ is the time difference and $t$ is the time you are starting with. Your example would become $(24-4+00:00)$ mod $24$, which would be $(20+00:00)$ mod $24$, which would then become $20:00$.



        If you are keeping track of the date, you will have to decrement it, as the extra 24 hours added to the time difference will push the date forward one day.






        share|cite|improve this answer













        If you are not keeping track of the date, you can simply use $(24+d+t)$ mod $24$ where $d$ is the time difference and $t$ is the time you are starting with. Your example would become $(24-4+00:00)$ mod $24$, which would be $(20+00:00)$ mod $24$, which would then become $20:00$.



        If you are keeping track of the date, you will have to decrement it, as the extra 24 hours added to the time difference will push the date forward one day.







        share|cite|improve this answer













        share|cite|improve this answer



        share|cite|improve this answer











        answered Aug 1 at 3:56









        Nico

        213




        213






















             

            draft saved


            draft discarded


























             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2868459%2f24-hour-time-modulo%23new-answer', 'question_page');

            );

            Post as a guest













































































            Comments

            Popular posts from this blog

            What is the equation of a 3D cone with generalised tilt?

            Color the edges and diagonals of a regular polygon

            Relationship between determinant of matrix and determinant of adjoint?