[Python] Get datetime format from string python

Discussão em 'Python' iniciado por Stack, Setembro 27, 2024.

  1. Stack

    Stack Membro Participativo

    In Python there are multiple DateTime parsers which can parse a date string automatically without providing the datetime format. My problem is that I don't need to cast the datetime, I only need the datetime format.

    Example: From "2021-01-01", I want something like "%Y-%m-%d" or "yyyy-MM-dd".

    My only idea was to try casting with different formats and get the successful one, but I don't want to list every possible format.

    I'm working with pandas, so I can use methods that work either with series or the string DateTime parser.

    Any ideas?

    Continue reading...

Compartilhe esta Página