You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for stopping by to let us know something could be better!
PLEASE READ: If you have a support contract with Google, please create an issue in the support console instead of filing on GitHub. This will ensure a timely response.
Please run down the following list and make sure you've tried the usual "quick fixes":
The issue occurs because the due field was set using a local timezone offset like +01:00 (Europe timezone).
Google Tasks API internally stores the due field in UTC (Z) format.
Even if you send a local time with an offset, Google automatically converts it to UTC when saving.
Therefore, if you want to display the correct time in your local timezone (e.g., Europe/Paris), you need to manually convert it back when reading the API response.
✅ Solution:
When reading the due field from the API response, parse it as UTC and then convert it to your local timezone.
Here’s an example:
fromdatetimeimportdatetimefromzoneinfoimportZoneInfo# Python 3.9+ standard libraryfromgoogleapiclient.discoveryimportbuildfromgoogle.oauth2.credentialsimportCredentials# Set up credentialscreds=Credentials(TOKEN)
service=build('tasks', 'v1', credentials=creds)
# Patch the taskresult=service.tasks().patch(
tasklist="ZERNSFhRUWduTVFuOVV0UQ",
task="elo1NllBMlJ4TERCZ3Nucg",
body={
'title': 'Subitem',
'status': 'needsAction',
'due': '2024-12-14T00:00:00+01:00',
'notes': None,
'parent': 'OXRUelVzcFNjYWphbTl6Wg',
},
).execute()
# Convert 'due' field from UTC to Europe/Paris timezonedue_from_api=result.get('due')
ifdue_from_api:
# Parse the UTC timeutc_time=datetime.fromisoformat(due_from_api.replace('Z', '+00:00'))
# Convert to Europe/Paris timeparis_time=utc_time.astimezone(ZoneInfo('Europe/Paris'))
print(f"Due time in Europe/Paris timezone: {paris_time.isoformat()}")
# Print the full resultprint(result)
✅ Summary:
Input: You can send the due time with a local timezone offset if necessary, but Google will store it in UTC.
Output: Always manually convert the UTC time back to your desired local timezone (e.g., Europe/Paris) after reading the API response.
This way, you can correctly display the due time without any timezone confusion.
Uh oh!
There was an error while loading. Please reload this page.
Thanks for stopping by to let us know something could be better!
PLEASE READ: If you have a support contract with Google, please create an issue in the support console instead of filing on GitHub. This will ensure a timely response.
Please run down the following list and make sure you've tried the usual "quick fixes":
If you are still having issues, please be sure to include as much information as possible:
Environment details
google-api-python-client
version: 2.155.0Steps to reproduce
Code example
Note the timestamp is
2024-12-14T00:00:00+01:00
.The result is:
Note the timestamp is
2024-12-13T00:00:00.000Z
.Stack trace
NA
Making sure to follow these steps will guarantee the quickest resolution possible.
Thanks!
The text was updated successfully, but these errors were encountered: