Getting a struct object_time UTC in Python
You can also get a struct_time
object using the gmtime
method of the time
module. In this case, the time will be output according to UTC - the world time standard, independent of the local time zone. This means that the result will be the same regardless of where exactly the calculations were made.
Let's get a struct_time
object using the gmtime
method:
now = time.time()
res = time.gmtime(now)
print(res)
After executing the code, the following will be displayed in the console:
time.struct_time(tm_year=2025, tm_mon=12,
tm_mday=31, tm_hour=15, tm_min=40, tm_sec=51, tm_wday=3,
tm_yday=365, tm_isdst=0)
Get hours and minutes from the struct_time
object in UTC. Compare the results with the localtime
method.