Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python datetime with timezone

import datetime
import pytz

d = datetime.datetime.now()
timezone = pytz.timezone("America/Los_Angeles")

# List of Time Zones: https://gist.github.com/heyalexej/8bf688fd67d7199be4a1682b3eec7568
d_aware = timezone.localize(d)
d_aware.tzinfo

# One Liner
timezone.localize(datetime.datetime.now())

# Timestamp to Datetime with timezone
datetime.fromtimestamp(3456789, timezone)
 
PREVIOUS NEXT
Tagged: #python #datetime #timezone
ADD COMMENT
Topic
Name
4+6 =