I'm doing a countdown on a cms. I have to modularize this. Modularizing is creating fields to enter information without messing with the code. Being able to change any information available without changing the text or values in the code.
Building this structure or form, it provides an input to put the date. But if I put "2021/07/14", it shows me as "2021/07/13, 21:00". I only need the date as this time will be defined in another field.
The problem is that it already takes that date and turns it into milliseconds.
How can I work this date and change this time??
For your interest, the CMS is Liferay
function orangeWeeek() {
let dataliferay = new Date($main.contagemregressiva.contagemregressiva_data.getData() $main.contagemregressiva.contagemregressiva_hora.getData())
console.log(dataliferay)
// Countdown
function countdown() {
let tagDay = document.getElementById("orangeWeek_countdown_time_days");
let tagHours = document.getElementById("orangeWeek_countdown_time_hours");
let tagMinutes = document.getElementById("orangeWeek_countdown_time_minutes");
let futureDate = $main.contagemregressiva.contagemregressiva_data.getData()
// Update countdown
function updateCountdown() {
const currentDate = new Date();
const difference = futureDate - currentDate;
// Calculate the values
const days = Math.floor(difference / 1000 / 60 / 60 / 24);
const hours = Math.floor(difference / 1000 / 60 / 60) % 24;
const minutes = Math.floor(difference / 1000 / 60) % 60;
insertValuesHtml(days, hours, minutes)
}
// Insert values into html
function insertValuesHtml(days, hours, minutes){
tagDay.textContent = check_lessThanTen(days);
tagHours.textContent = check_lessThanTen(hours);
tagMinutes.textContent = check_lessThanTen(minutes);
}
// Check if the value is less than ten
let check_lessThanTen = variable => variable < 10 ? '0' + variable : variable;
updateCountdown()
setInterval(() => {
updateCountdown()
}, 1000);
}countdown()
}orangeWeeek()
$main.contagemregressiva.contagemregressiva_data.getData() this here is a template language called velocity. It's the language I use in liferay to call form/structure fields