API doesn't know date, thinks it's 2022

Despite regular GPT knowing the date and the training data being updated, the regular gpt-4 API seems to have no idea. Asking it to do a new year’s announcement and include the date it says it’s 2022. If you ask the date, it refuses to answer, while GPT-4 on ChatGPT can do this.

1 Like

This is because GPT-4 on the API does not have access to web browsing while GPT-4 at chat.openai.com does.

I don’t it browsing or gpt-4 classic also knows the date. Regardless, it’s a small thing for the AI to know the date but functionally signifciant, since there are lots of tasks that not knowing the date can cause it to fail. For instance if we are using a function call and asking it to identify a budget from this year. The model never knew what this year was so it just fails. It think it’s 2022, even it’s worse than not knowing it’s erroneous.

In that case, you can add the following to the API’s system messages

import datetime
import pytz

your_locale = pytz.timezone('Your locale goes here')
datetime = datetime.datetime.now(your_locale)
            now_of_year = datetime.strftime("%Y")
            now_of_month = datetime.strftime("%m")
            now_of_day = datetime.strftime("%d")
            now_of_time = datetime.strftime("%H:%M")
            system_message_content = f"Today is the year {now_of_year}, month is {now_of_month}, and date is " \
                                          f"{now_of_day}. " \
                                          f"The current time is {now_of_time}. "

Alternatively, you can indicate the current date.

Current date is: {datetime goes here}

In ChatGPT, there may be some information or prompts about knowledge cutoffs that is not visible to the user, but you need to make it explicit if you want to use the API.

I hope this will be of some help to you.


As has been alluded to by @grandell1234 and @dignity_for_all, the API only has access to the data it was trained on and there is nothing inherent in a GPT model which would allow it to know the date.

The web interface includes the current date in its system message. To get the same functionality where the model you access via the API knows the current date you just need to include the current date in the system message.

In both the completions API and the Assistant API it is pretty straighforward to add the current date (and other this that you would like the assistant to ‘know’ to the beginning of the chat.

1 Like

ChatGPT includes the current date in the system message.