Quantcast
Viewing latest article 9
Browse Latest Browse All 55

Answer by Kanish Mathew for Convert string "Jun 1 2005 1:33PM" into datetime

It would do the helpful for converting string to datetime and also with time zone

def convert_string_to_time(date_string, timezone):    from datetime import datetime    import pytz    date_time_obj = datetime.strptime(date_string[:26], '%Y-%m-%d %H:%M:%S.%f')    date_time_obj_timezone = pytz.timezone(timezone).localize(date_time_obj)    return date_time_obj_timezonedate = '2018-08-14 13:09:24.543953+00:00'TIME_ZONE = 'UTC'date_time_obj_timezone = convert_string_to_time(date, TIME_ZONE)

Viewing latest article 9
Browse Latest Browse All 55

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>