In Python, you can convert GMT time to Eastern time using the pytz
library. Here's an example:
main.py304 chars12 lines
This will output: 2021-01-01 07:00:00-05:00
Note that the -05:00
at the end of the output indicates the timezone offset from UTC for Eastern time. If you want to display the Eastern time in a specific format, you can use the strftime()
method of the datetime
object, like this:
main.py85 chars3 lines
This will output: 2021-01-01 07:00:00 EST
gistlibby LogSnag