24 hour time modulo
Clash 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).
discrete-mathematics modular-arithmetic
add a comment |Â
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).
discrete-mathematics modular-arithmetic
4
Just add $24$ and adjust the date.
– Math Lover
Jul 31 at 20:40
add a comment |Â
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).
discrete-mathematics modular-arithmetic
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).
discrete-mathematics modular-arithmetic
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
add a comment |Â
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
add a comment |Â
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.
add a comment |Â
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.
add a comment |Â
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.
add a comment |Â
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.
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.
answered Aug 1 at 3:56
Nico
213
213
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
4
Just add $24$ and adjust the date.
– Math Lover
Jul 31 at 20:40