devxlogo

Days Left Until Specific Date

Days Left Until Specific Date

Using the Date functionality in JavaScript, you can post the number of days left until a certain date. Internally, JavaScript stores dates as the number of milliseconds from midnight (GMT) on January 1, 1970. If you subtract two Date objects, the result is the number of milliseconds between the two dates. The following code sample subtracts the future (target) date from today’s date (returned by Date() with no arguments) and then multiplies to convert milliseconds into days.

 There are only datediff('July4, 2000'); days left untilliftoff.

devx-admin

Share the Post: