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?
Yes, your formula is a perfectly good way of doing that. Another way of accomplishing the same thing is:
It may be worth noting that the above formula assumes integer (truncating) division. Also, I feel that
86400is a sufficiently commonly used constant that it can appear in source code without additional comment.