programming-examples/js/_Basic/Write a JavaScript program to calculate number of days left until next Christmas..js
2019-11-15 12:59:38 +01:00

9 lines
311 B
JavaScript

today=new Date();
var cmas=new Date(today.getFullYear(), 11, 25);
if (today.getMonth()==11 && today.getDate()>25)
{
cmas.setFullYear(cmas.getFullYear()+1);
}
var one_day=1000*60*60*24;
console.log(Math.ceil((cmas.getTime()-today.getTime())/(one_day))+
" days left until Christmas!");