Created
October 22, 2019 16:44
-
-
Save bugcy013/ce1976aee00465d274f4b07799ff9412 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from datetime import datetime | |
| import pytz | |
| date_str = "2019-10-22T10:45:35Z" | |
| utc_datetime_obj = pytz.utc.localize(datetime.strptime(date_str, "%Y-%m-%dT%H:%M:%SZ")) | |
| ist_datetime_obj = utc_datetime_obj.astimezone(pytz.timezone("Asia/Kolkata"))\ | |
| # .strftime("%Y-%m-%d %H:%M:%S") | |
| # print(type(datetime_obj)) | |
| # datetime_obj_utc = datetime_obj.replace(tzinfo=timezone('UTC')) | |
| # print(datetime_obj_utc.strftime("%Y-%m-%d %H:%M:%S")) | |
| print(utc_datetime_obj) | |
| print(ist_datetime_obj) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment