Python ProgrammingPython Programming

Get current date time in MST, EST, UTC, GMT and HST

The following code snippet illustrates use of pytz and datetime to display current date and time in various MST, EST, UTC, GMT and HST
# Python's program to get current time MST EST UTC GMT HST

from datetime import datetime
from pytz import timezone

mst = timezone('MST')
print("Time in MST:",

est = timezone('EST')
print("Time in EST:",

utc = timezone('UTC')
print("Time in UTC:",

gmt = timezone('GMT')
print("Time in GMT:",

hst = timezone('HST')
print("Time in HST:",

Sample output of above program.
C:\programs\time>pep8 --first

Time in MST: 2017-01-19 06:06:14.495605-07:00
Time in EST: 2017-01-19 08:06:14.496606-05:00
Time in UTC: 2017-01-19 13:06:14.496606+00:00
Time in GMT: 2017-01-19 13:06:14.496606+00:00
Time in HST: 2017-01-19 03:06:14.497606-10:00