T
Typebot4mo ago
Lucas

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')
Modern JavaScript Date Utility Library
date-fns provides the most comprehensive yet simple and consistent toolset for manipulating JavaScript dates in a browser & Node.js.
No description
3 Replies
Baptiste
Baptiste4mo ago
You don't have access to that package in Typebot code environment Here is how you can do it natively:
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
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
Lucas
Lucas4mo ago
Thanks @Baptiste!!!
caioguibr
caioguibr2w ago
how can i use variable from previous collected information from user inside de code?
Want results from more Discord servers?
Add your server