gmail-api

When I am using the Gmail API to list all messages, I am unable to add filter based on time (specifically hours)


While trying to list mails using Gmail API, I am trying to fetch mails with a filter that I only want mails from the past one hour. But it doesn't work. Is that a limitation?

What is working: after:2024-08-12
When using this, I was able to fetch the list of mails after that time.

What I want and is not working: after:2024-08-12T09:27:27Z
I expected a similar functionality here as well, but I was getting null.


Solution

  • Gmail API: Filtering Emails

    The Gmail API supports filtering emails by date using the 'after' or 'before' parameter in YYYY-MM-DD format, which follows the RFC3339 standard. However, filtering by a specific timestamp, such as in your case, after:2024-08-12T09:27:27Z, is not supported since this uses the ISO 8601 format.

    References: