"need to convert utc (aws ec2) to pst in python" Code Answer

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

By sion_corn on January 20 2022

Answers related to “need to convert utc (aws ec2) to pst in python”

Only authorized users can answer the Search term. Please sign in first, or register a free account.