Python datetime.utctimetuple() Method

Beginner
6 min read
Updated: Nov 2026
3 examples
datetime method

Definition

utctimetuple() returns a time.struct_time describing the value in UTC. For an aware datetime it first subtracts utcoffset(); for a naive datetime it uses the fields as they are, assuming they already mean UTC.

The tm_isdst flag is always 0, because UTC has no daylight saving time. Combined with calendar.timegm() it gives whole epoch seconds without depending on the local time zone.

datetime.utctimetuple() is an instance method of datetime.datetime: call it on an existing object with dot notation, such as moment.utctimetuple(...). Import the class first, for example from datetime import datetime.

Syntax

Call it with no arguments.

python
tt = moment.utctimetuple()
CallWhat it does
datetime(2024, 3, 15, 2, 0, tzinfo=ist).utctimetuple().tm_mdayGives 14 when ist is UTC+05:30, because 02:00 there is 20:30 UTC the day before.
datetime(2024, 3, 15, 10, 30).utctimetuple().tm_hourReturns 10: a naive value is used unchanged.
datetime(2024, 7, 1, tzinfo=timezone.utc).utctimetuple().tm_isdstReturns 0: always 0 here.

Only datetime has this method; date objects do not.

Method signatures
python
datetime.utctimetuple()
# returns: time.struct_time in UTC with tm_isdst == 0

Parameters

utctimetuple() takes no parameters.

Return Value

Return ValueDescription
time.struct_timeThe UTC fields of the moment, weekday Monday = 0, day of year from 1, and tm_isdst=0.

Python Examples

Example 1 — Compare timetuple() and utctimetuple()

An early-morning time at UTC+05:30 is still the previous evening in UTC.

python
from datetime import datetime, timedelta, timezone

ist = timezone(timedelta(hours=5, minutes=30))
moment = datetime(2024, 3, 15, 2, 0, tzinfo=ist)

local_tt = moment.timetuple()
utc_tt = moment.utctimetuple()
print(local_tt.tm_mday, local_tt.tm_hour, local_tt.tm_isdst)
print(utc_tt.tm_mday, utc_tt.tm_hour, utc_tt.tm_isdst)

How It Works

  1. Wall-clock tuple. timetuple() keeps 15 March 02:00 and reports DST as unknown (-1).
  2. Shifted to UTC. Subtracting 5 hours 30 minutes gives 20:30 on 14 March.
  3. DST flag zero. The UTC tuple always reports tm_isdst=0.

Example 2 — Get Epoch Seconds with calendar.timegm()

calendar.timegm() reads a UTC struct_time, so it pairs with utctimetuple(). Compare it with timestamp(), which keeps fractions.

python
import calendar
from datetime import datetime, timedelta, timezone

ist = timezone(timedelta(hours=5, minutes=30))
moment = datetime(2024, 3, 15, 16, 0, 45, tzinfo=ist)
seconds = calendar.timegm(moment.utctimetuple())

print(seconds)
print(seconds == int(moment.timestamp()))
precise = moment.replace(microsecond=750000)
print(calendar.timegm(precise.utctimetuple()), precise.timestamp())

How It Works

  1. UTC first. 16:00:45 at UTC+05:30 is 10:30:45 UTC, which is 1710498645 seconds after the epoch.
  2. Matches timestamp(). For a whole-second value the integer from timegm() equals timestamp().
  3. Fractions dropped. struct_time has no microseconds, so timegm() loses the .75 that timestamp() keeps.

Example 3 — Naive Values Are Used As They Are

A naive datetime is assumed to be UTC already: the fields are copied and the DST flag becomes 0.

python
from datetime import datetime

naive = datetime(2024, 12, 31, 23, 59, 59)
tt = naive.utctimetuple()
print(tt.tm_year, tt.tm_yday, tt.tm_hour, tt.tm_isdst)
print(naive.timetuple().tm_isdst)
print(tuple(tt)[:6])

How It Works

  1. No conversion. The naive fields go straight into the tuple; 31 December is day 366 of 2024.
  2. Different DST flags. utctimetuple() says 0, while timetuple() says -1 for the same naive value.
  3. Plain tuple. tuple(tt) turns the struct into a normal tuple you can slice.

Frequently Asked Questions

timetuple() keeps the wall-clock fields; utctimetuple() converts aware values to UTC and sets tm_isdst to 0.
For an aware value use calendar.timegm(moment.utctimetuple()) or int(moment.timestamp()).
No. It assumes they are already UTC and copies the fields.
UTC never has daylight saving time.
No, only datetime does. Use date.timetuple() for dates.

Next: datetime.utcnow()

Deprecated classmethod: current UTC time as a naive datetime; use now(timezone.utc).

utcnow() →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

16 people found this page helpful