I need to convert UTC time, (on ec2 instance) to PST. I am trying to do this.
from datetime import datetime
from pytz import timezone
import pytz
date_form
I think you want datetime.utcnow() if you are attempting to simulate UTC time in your example.
The other issue is that by default the object has no timezone. This does not mean that it is UTC, and I think pytz is just defaulting to localtime for that object. You need to create a new datetime object with the timezone set as UTC before you try to convert it to PST.
You can do this via
date = datetime.utcnow()
date.replace(tzinfo=pytz.utc)