Midnight in UTC time zone with unix timestamp
math, unix-timestamp
Solution
Yes, your formula is a perfectly good way of doing that. Another way of accomplishing the same thing is:
date = (date / 86400) * 86400;
It may be worth noting that the above formula assumes integer (truncating) division. Also, I feel that `86400` is a sufficiently commonly used constant that it can appear in source code without additional comment.
Problem
I was looking for a numeric representation for a date and unix time for midnight (in UTC) seems to be reasonable choice for that. However, as I'm not sure in my math skills, so is ``` date = date - date % (24 * 60 * 60); ``` where `date` is unix timestamp, the way to do that? Is there any simpler method?