There are the following options for the textual representation of time:

12.03.2019 в 13:00 14.02.2019 12:00 

Task:

It is required to translate the test time format in Unix eras

    1 answer 1

    Use the built-in datetime module.

     from datetime import datetime tik = datetime.strptime('04.03.2019 18:55', '%d.%m.%Y %H:%M') print(tik.timestamp()) 

    1551714900.0

    • And if something like this happens: 03/05/2019 (MSK + 7)? How to clear such a line from all the excess? How can you clear a string of unnecessary information if it comes across? - Sergey Andreev
    • In my opinion, the easiest way is to use regular expressions. Something like re.findall(r'\d{2}\.\d{2}\.\d{2,4}', '05.03.2019 (МСК+7)') . But you need to know in advance all possible formats in which the date and time can occur. - mymedia