I am using Javascript for Parse.com Cloud Code. According to Parse.com they return UTC time. I am in EDT (GMT -4)
I'm trying to get today's date at midnight to no avail. Here is my code:
var date = new Date();
var startDay = Math.floor((date.setUTCHours(4,0,0,0) / 1000));
So before 8pm on each day, the code returns today's date at midnight which is what I want. However, after 8pm it returns tomorrow's date at midnight. I believe the reason is due to the UTC date changing to Today+1 at midnight. But I cant figure out how to resolve this issue in a way that I get my local date at midgnight.
PS:
I also tried setHours(4,0,0,0)
in vain.
If I use setUTCHours(0,0,0,0)
it returns today's date at 8pm
Thank you for your help.