Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
This is the current hour of the year... but rolled back to the beginning of the day.
var timestmp = new Date().setFullYear(new Date().getFullYear(), 0, 1);
var yearFirstDay = Math.floor(timestmp / 86400000);
var today = Math.ceil((new Date().getTime()) / 86400000);
var dayOfYear = today - yearFirstDay;
var currentHourOfYear = dayOfYear * 24 - 24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment