How do I calculate time interval in javascript. I want to create a javascript that will except a DateTime value. Once the date is received, I would like to calculate the differenct between current date and the date parameters received by the function. once that is calculated, I want to use the calculated interval as input parameter to the setTimeout javascript method.

can anyone help me?

Subtracting two date variables gives the difference between them, but in an internal representation.

getTime will then give the number of milliseconds between the two times.

Divide that value by 86400000 to get the difference in days. Real division will give days and portions of days.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.