Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function calcPassedPercentageInThisYear(date) {
- var thisNewYear = new Date(date.getFullYear() + "/1/1");
- var nextNewYear = new Date((date.getFullYear()+1) + "/1/1");
- return 1 - (nextNewYear - date) / (nextNewYear - thisNewYear);
- }
- var date = new Date();
- var passedPercentageInThisYear = Math.round(calcPassedPercentageInThisYear(date) * 10000.0) / 100.0;
- console.log(passedPercentageInThisYear + " percent has passed in this year!");
Add Comment
Please, Sign In to add comment