green oranges

Sat, 02 May 2026 23:32:37 +0000

For Python 3, use datetime.now(timezone.utc) to get a timezone-aware datetime, and use .timestamp() to convert it to a timestamp. When I create a new Date object, it is initialized to the current time but in the local timezone. How can I get the current date and time in GMT? I have a timezone which is float (for example 4.0). I want to construct datetime with given timezone. I tried this, datetime.now(timezone) but it throws TypeError: tzinfo argument must be None ... The resulting utc object isn't really a UTC date, but a local date shifted to match the UTC time (see comments). However, in practice it does the job. Update: The above answer from 2012 was a quick.