Share feedback, ideas and get community help

Home
Members
Thiago Lima
T
Thiago Lima
Offline, last seen 3 months ago
Joined September 13, 2024
Hello Everyone!
I am looking to understand how to proceed with JavaScript Block interact with Condition Block, this is my JS script.
Basically I am converting a timestamp date to DD/MM/YYYY and checking after convertion if the date is 7 days ahead or no.

var setVariable{{diferencaDias}};

function verificarPrazo({{DATAINICIOASSINATURA}}) {
const data = new Date(timestamp);

const dia = String(data.getDate()).padStart(2, '0');
const mes = String(data.getMonth() + 1).padStart(2, '0'); // Janeiro é 0!
const ano = data.getFullYear();
const dataFormatada = dia + '/' + mes + '/' + ano;

const agora = new Date();
const diferencaTempo = agora.getTime() - data.getTime();
diferencaDias = diferencaTempo / (1000 * 3600 * 24);

if ({{diferencaDias}} > 7) {
setVariable({{FORADOPRAZO}});
} else {
setVariable({{DENTRODOPRAZO}});
}
}
6 comments
B
T