Agent not knowing dates correctly
# support
e
When people talk to my agent, it says the wrong day of the week. Like if it’s June 1, it says that it’s a Friday when it’s really a Sunday coming up
v
It sounds like your agent may be using UTC by default, which can cause the day of the week to be off for your users' local time. To fix this, explicitly set the timezone in your date formatting using LiquidJS in your prompt, like this:
Copy code
{{"now" | date: "%A, %B %d, %Y", "America/New_York"}}
Replace
"America/New_York"
with your desired timezone. This should ensure the correct day of the week is spoken to users. Tip: Always specify the timezone to avoid mismatches between UTC and your users' local time. Source: - [Using dynamic variables in a phone call](https://docs.vapi.ai/assistants/dynamic-variables)
k
^ Using the date variable in your prompt is key to getting the correct day of the week
e
Do I have to replace the "A", "B", "d" and "Y" with something or just make sure the time zone is correct?
It was not working to just make it "America/Los_Angeles"
v
You do not need to replace the
%A
,
%B
,
%d
, or `%Y`—these are standard format codes that LiquidJS will automatically fill in for you. Just make sure your timezone is set correctly. For example:
Copy code
liquid
{{"now" | date: "%A, %B %d, %Y", "America/New_York"}}
This will output the correct day of the week and date for your specified timezone. Tip: Only change the format string if you want a different output style; otherwise, leave it as is for standard results. Source: - [Using dynamic variables in a phone call](https://docs.vapi.ai/assistants/dynamic-variables#advanced-date-and-time-usage)
You do not need to replace the
%A
,
%B
,
%d
, or `%Y`—these are standard format codes that LiquidJS will automatically fill in for you. Just make sure your timezone is set correctly. For example:
Copy code
liquid
{{"now" | date: "%A, %B %d, %Y", "America/New_York"}}
This will output the correct day of the week and date for your specified timezone. Tip: Only change the format string if you want a different output style; otherwise, leave it as is for standard results. Source: - [Using dynamic variables in a phone call](https://docs.vapi.ai/assistants/dynamic-variables#advanced-date-and-time-usage)
You do not need to replace
%A
,
%B
,
%d
, or `%Y`—these are standard date format codes. Just make sure your prompt uses the correct syntax and timezone, like this:
Copy code
liquid
{{"now" | date: "%A, %B %d, %Y", "America/Los_Angeles"}}
If this still doesn't work, double-check for typos and ensure your environment supports the specified timezone. Reference: [Vapi dynamic variables documentation](https://docs.vapi.ai/assistants/dynamic-variables) Source: - [Using dynamic variables in a phone call](https://docs.vapi.ai/assistants/dynamic-variables)
You do not need to replace
%A
,
%B
,
%d
, or `%Y`—these are standard date format codes. Just make sure your prompt uses the correct syntax and timezone, like this:
Copy code
liquid
{{"now" | date: "%A, %B %d, %Y", "America/Los_Angeles"}}
If this still doesn't work, double-check for typos and ensure your environment supports the specified timezone. Reference: [Vapi dynamic variables documentation](https://docs.vapi.ai/assistants/dynamic-variables) Source: - [Using dynamic variables in a phone call](https://docs.vapi.ai/assistants/dynamic-variables)
e
It seems to be working now that I added to the prompt to use the 2025 calendar but that’s only a short term fix because I don’t want to have to update it every year
v
You do not need to update the year in your prompt each year. To always get the correct day of the week and date, use the following syntax and set your desired timezone:
Copy code
liquid
{{"now" | date: "%A, %B %d, %Y", "America/Los_Angeles"}}
This will automatically use the current date and year. If you still see issues, double-check for typos and ensure your environment supports the specified timezone. Reference: [Vapi dynamic variables documentation](https://docs.vapi.ai/assistants/dynamic-variables#advanced-date-and-time-usage) Source: - [Using dynamic variables in a phone call](https://docs.vapi.ai/assistants/dynamic-variables#advanced-date-and-time-usage)
e
That wasn't working to just do that without me saying "use 2025"
k
Could you send a copy of your prompt or at least the snippet that includes the date formatting and where it says "use 2025". A call id would also be helpful information for investigation purposes
e
Today I had someone demo it and they didn’t know the date they wanted and it thought that two months from now was December. I’ll send over the prompt shortly
This is what I did to make it understand what the day of the week was, as long as a date is provided: - Weekday or Weekend Rate - if the date they want to move is Monday, Tuesday, Wednesday Thursday, that is considered a Weekday rate and if it is Friday, Saturday, or Sunday and use {{"now" | date: "%A, %B %d, %Y", "America/Los_Angeles"}} to calculate which day of the week they are moving based on the 2025 calendar.
I haven't tested if this helps yet, but I just added: - Today's date is {{"now" | date: "%A, %B %d, %Y", "America/Los_Angeles"}}
If you see any way to improve, please let me know!
I just tested it and said the same thing to it that caused the error and it knew that two months from now was the end of july, so that's good
The concern we have is that we don't want to have to update the prompt every year with 2026, 2027, etc. Especially near the end of the year where they may want to book Nov/Dec '25 or could also be Jan/Feb '26
This was the call ID for the one where it thought two months from now was in December: 5107e651-e5f6-4782-b1e3-326ae17aabe7
k
What you have added should work with your prompt. Explicitly telling the assistant what the current date and time is for today is crucial for getting accurate dates and since you are using the variables, you won't have to update it every year.
e
Ok I hope so!
k
Let us know how it goes