Share feedback, ideas and get community help

Updated 7 months ago

Format Date: weekdays

How can I format a date to show the weekday?

I used a formatting token that is on library (https://date-fns.org/v3.6.0/docs/format) as you can see in the picture attached, but the output was the formula set:
format(new Date(2024-05-22T16:53:03.682Z), 'EEEE')
Attachment
Weekday_TypeBot.png
B
L
c
4 comments
You don't have access to that package in Typebot code environment
Here is how you can do it natively:

Plain Text
const dateStr = '2024-05-22T16:53:03.682Z';

const date = new Date(dateStr);
const daysOfWeek = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
const dayName = daysOfWeek[date.getUTCDay()];

return dayName
Thanks @Baptiste!!!
how can i use variable from previous collected information from user inside de code?
Add a reply
Sign up and join the conversation on Discord