When using the $now expression, which currently returns [Object: “2023-11-24T23:41:14.595-05:00”], when I use the format node MM/DD/YYYY, I get 11/25/2023, instead of 11/24/2023.
This is occurring in template 1744 as well as in my own workflow I built separately.
What is the error message (if any)?
Please share your workflow
(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)
Javascript in the Code Node has the same issue, as this returns 2023-11-25 instead of 2023-11-24. It’s almost like the timezone is in Germany where n8n.io is hosted??
// Create a new Date object
const today = new Date();
// Get the year, month, and day separately
const year = today.getFullYear();
// JavaScript months are zero-based (0 for January, 1 for February, etc.)
const month = today.getMonth() + 1; // Adding 1 to get the actual month
const day = today.getDate();
// Format the date as yyyy-mm-dd
const formattedDate = ${year}-${month.toString().padStart(2, '0')}-${day.toString().padStart(2, '0')};
return {formattedDate} ; // Output: yyyy-mm-dd format of today’s date
Inside settings you will find the Timezone.
Let me know if that helps.
A side note: n8n uses the Luxon javascript library, so you can easily format your dates writing something like: $now.toFormat('LL/dd/yyyy)
You can find the full list of Luxon’s tokens here: luxon - Immutable date wrapper
Hi @ManOnFire1978
that template is using old versions of our nodes,
I suggest trying to replace the nodes with the new ones, that could make your life easier (and also get you used to our most recent nodes).
Let me know if that works
Best