Timestamp formatting in python

I have a timestamp in the below format - Fri 6Jun21 11:11:11.402 pm

and I'd like to do two things -

  1. add proceeding 0 before 6Jun21 so it reads 06Jun21, and ignore for double digit occurrences
  2. Convert time into 24h format

Final output should look like Fri 06Jun21 23:11:11.402

I tried traditional formatting and unable to do so. I'm trying to avoid parsing as regex and add an overhead on my processing.

Any ideas?



Read more here: https://stackoverflow.com/questions/67938993/timestamp-formatting-in-python

Content Attribution

This content was originally published by themlchic at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: