How to convert an unformatted string to date and time in python

  date, datetime, python

Say I have a 10 digit string with the first 6 digits being a date and the last 4 digits being military time.

1504230001

The first 2 digits are year, next 2 are month, next 2 are day. The remaining 4 digits are for military time

Desired output:

2015-04-23 00:01:00

Source: Python Questions

LEAVE A COMMENT