Answer the question
In order to leave comments, you need to log in
How to transform the correct date in JS?
Hello! Tell me how to correctly write the date in cookies so that it turns out for 1 day, now this entry is not very clear to me (var ms = days*24*60*60*1000;) and for what period of time does it work!?
function setDefaultCookieExpire(days) {
// transform days to milliseconds
var ms = days*24*60*60*1000;
var date = new Date();
date.setTime(date.getTime() + ms);
return "; expires=" + date.toUTCString();
}
Answer the question
In order to leave comments, you need to log in
Дни * Часы * Минуты * Секунды * Миллисекунды
. And the number of days you have as a parameter comes.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question