But sometimes, we would like to treat any time in the same day the same way, which means we don’t want to know the hour, minute, second of the day. We just care about the day.
You can always convert the date to string and ignore the hours etc. which is inefficient. It’s also problematical if we need to save the date into db. So convert to string then convert back to time stamp is necessary but make it more inefficient.
Today I am showing a pure mathematical way.
TodayUTCZeroOClock = Now – Now%DayInMiniSeconds
a = Date.now()
day = 1000 * 60 * 60 * 24
b = a – a%day
Thu Mar 14 2019 13:00:00 GMT+1300 (New Zealand Daylight Time)
Note that 13 O’clock is UTC 0 0’clock