how to calculate the beginning of a day given milliseconds?
Posted
by
conman
on Stack Overflow
See other posts from Stack Overflow
or by conman
Published on 2012-06-22T02:43:35Z
Indexed on
2012/06/22
3:16 UTC
Read the original article
Hit count: 177
i want to figure out the time from the beginning of the day given a days milliseconds.
so say i'm given this: 1340323100024 which is like mid day of 6/21/2012. now i want the milliseconds from the beginning of the day, which would be 1340262000000 (at least i think that's what it's supposed to be.)
how do i get 1340262000000 from 1340323100024?
i tried doing
Math.floor(1340323100024/86400000) * 86400000
but that gives me 1340236800000, which if i create a date object out of it, says its the 20th.
i know i can create a date object from 1340323100024, then get the month, year, and date, to create a new object which would give me 1340262000000, but i find it ridiculous i can't figure out something so simple.
any help would be appreciated.
btw, i'm doing this in javascript if it makes any difference.
© Stack Overflow or respective owner