From 113731ab0711dd39d9c9dd0931c94636a5b95a86 Mon Sep 17 00:00:00 2001 From: Louise Farrow <117589972+Feyangol@users.noreply.github.com> Date: Tue, 22 Nov 2022 11:00:42 -0500 Subject: [PATCH] Create Date calculation --- Date calculation | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Date calculation diff --git a/Date calculation b/Date calculation new file mode 100644 index 00000000..f341ebb2 --- /dev/null +++ b/Date calculation @@ -0,0 +1,26 @@ +//1- lowest to now +//2 -highest to now +function remaning_time(Выбранная_дата, Тип_отсчета){ + var tDate = new Date; + var sec = 1000; + var min = 60*sec; + var hour = 60*min; + var day = 24*hour; +// 1 - means lowest date to current date + if(Тип_отсчета == 1){ + var diff = tDate-Выбранная_дата; + var days = Math.floor(diff/day); + var hours = Math.floor(diff%day/hour); + var minutes = Math.floor(diff%day%hour/min); + return ['> ' + days + 'dd. ' + hours + 'hh. ' + minutes + 'mm.']; + } +// 2 - means highest date to current date + if(Тип_отсчета == 2){ + var diff=Выбранная_дата-tDate; + var days = Math.floor(diff/day); + var hours = Math.floor(diff%day/hour); + var minutes = Math.floor(diff%day%hour/min); + return [days + 'д. ' + hours + 'ч. ' + minutes + 'м.'+ ' >']; + } + +}