To convert from GMT to Australian Central Standard Time in Python, you can use datetime, timezone, timedelta modules.
main.py355 chars11 lines
In the above code, we set the input datetime as 2021-03-15 10:30:00 in the GMT timezone by using the datetime
and timezone
modules. We then use the astimezone
method to convert the input datetime to Australian Central Standard Time by passing the timezone offset of 9.5 hours to the timezone
constructor. Finally, we print the output datetime using the print
function.
Note: The above code assumes that the input datetime is in the GMT timezone. If the input datetime is in a different timezone, you need to convert it to the GMT timezone first before applying the above code.
gistlibby LogSnag