need to convert UTC (aws ec2) to PST in Python

from datetime import datetime
from pytz import timezone
import pytz

date_format="%m/%d/%Y %H:%M:%S %Z"
date = datetime.now(tz=pytz.utc)
print 'Current date & time is:', date.strftime(date_format)

date = date.astimezone(timezone('US/Pacific'))

print 'Local date & time is  :', date.strftime(date_format)

seems to work for me 🙂 – timezones are confusing, slowly making a plan of what I actually want to do helps me most of the time

Leave a Comment