Follow along with the video below to see how to install our site as a web app on your home screen.
Примечание: This feature currently requires accessing the site using the built-in Safari browser.
Есть допустим 2 даты
var d1 = new Date('2020-07-12 14:09:59');
var d2 = new Date('2020-07-18 13:44:55');
Нужно каждую сравнить с текущим временем - 1 неделя и для
d1 вернуть true
d2 вернуть false
var compare_dates = function(date1,date2){
if (date1>date2) return ("Date1 > Date2");
else if (date1<date2) return ("Date2 > Date1");
else return ("Date1 = Date2");
}
console.log(compare_dates(new Date('11/14/2013 00:00'), new Date('11/14/2013 00:00')));
console.log(compare_dates(new Date('11/14/2013 00:01'), new Date('11/14/2013 00:00')));
console.log(compare_dates(new Date('11/14/2013 00:00'), new Date('11/14/2013 00:01')));
Создает объект currentDate, который представляет текущую дату и время на момент выполнения кода.А зачем он нужен?
Код:// Получаем текущую дату и время var currentDate = new Date(); // Вычитаем одну неделю (7 дней) из текущей даты и времени currentDate.setDate(currentDate.getDate() - 7);