Automatically determine today's date
Hello could you please help me?
How can my assistant automatically determine today's date?
5 Replies
Use a Set variable block with the
Now
option 🙂Hi Batiste! I tried to use JS to format Now's output into a variable, for example {{data_agora}}, I looked in the documentation but couldn't find it. How can I format this date to DD/MM/YYYY? How to concatenate inline? {{=={{date_now}}.formatDate(DD:MM:YY)==}} ?
I use this variable
const currentDate = new Date();
const humanFriendlyDate = currentDate.toLocaleString();
return humanFriendlyDate;
so to can have the variable that's manageable in my flow with this format DD/MM/YYYY, HH:MM:SS AM
Perfetto! Thanks!
const currentDate = new Date();
// Format date DD/MM/YYYY
function formatDate(date) {
const day = String(date.getDate()).padStart(2, '0');
const month = String(date.getMonth() + 1).padStart(2, '0'); // Month init 0
const year = date.getFullYear();
return
${day}/${month}/${year};
}
const humanFriendlyDate = formatDate(currentDate);
return humanFriendlyDate;
happy to have helped you