Full version: jsB@nk » Time » Counter » Display days remaining in year
URL: https://www.javascriptbank.com/display-days-remaining-in-year.html
Use this JavaScript to calculate the number of days between now and the end of the year.
Full version: jsB@nk » Time » Counter » Display days remaining in year
URL: https://www.javascriptbank.com/display-days-remaining-in-year.html
<SCRIPT LANGUAGE="JavaScript"><!-- Beginfunction days_between(date1, date2) { // The number of milliseconds in one day var ONE_DAY = 1000 * 60 * 60 * 24 // Convert both dates to milliseconds var date1_ms = date1.getTime() var date2_ms = date2.getTime() // Calculate the difference in milliseconds var difference_ms = Math.abs(date1_ms - date2_ms) // Convert back to days and return return Math.round(difference_ms/ONE_DAY)}// End --></script><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->
<SCRIPT LANGUAGE="JavaScript"><!-- Begin// Store the current date and timevar current_date = new Date()// Store the date of the next New Year's Dayvar new_years_date = new Date()new_years_date.setYear(new_years_date.getFullYear() + 1)new_years_date.setMonth(0)new_years_date.setDate(1)// Call the days_between functionvar days_left = days_between(current_date, new_years_date)// Write the result to the pageif (days_left > 1) { document.write("<b>There are " + days_left + " days left this year.</b>")}else { document.write("<b>There is " + days_left + " day left this year.</b>")}// End --></script><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->