Skip to content

Instantly share code, notes, and snippets.

@vladwa
Created December 31, 2017 07:38
Show Gist options
  • Save vladwa/8cd97099e32c1088025dfaca5f1bfd33 to your computer and use it in GitHub Desktop.
Save vladwa/8cd97099e32c1088025dfaca5f1bfd33 to your computer and use it in GitHub Desktop.
Python snippet to get the PST time and date.
from datetime import datetime
from pytz import timezone
def get_pst_time():
date_format='%m_%d_%Y_%H_%M_%S_%Z'
date = datetime.now(tz=pytz.utc)
date = date.astimezone(timezone('US/Pacific'))
pstDateTime=date.strftime(date_format)
return pstDateTime
@abcjjy
Copy link

abcjjy commented Sep 16, 2021

Pacific time is different from PST. It switches to PST or PDT according to date.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment