I currently am setting a cookie in my code that last for 10 minutes. On the page I want to tell the person how many minutes are left before the cookie expires. So what I do is set Another code to keep the time when the cookie was set.
But I don’t know how to subtract the 2 time (the cookie time – current time).
For example, if I set the cookie at 12:55. How would I get the different between the time, lets say: 1:03 to get “2 minutes left”?
Really have no clue how to do this, but I hope you do.
You can just subtract dates in JavaScript.
will yield the number of milliseconds between them because the
-operator coerces its arguments to numbers which ends up callingDate.prototype.valueOfwhich just returns the number of milliseconds since the start of the epoch.