How to convert a string date to timestamp in Python

A timestamp measures the number of seconds that have passed since the Unix epoch January 1st, 1970. For example, converting the string date “25/01/2000” returns the timestamp 948758400.

Solution for How to convert a string date to timestamp in Python : You can use a datetime to convert a string date to timestamp Use datetime.datetime.strptime(date_string, format) with format as “%d/%m/%Y” to convert date_string to a datetime object. Use datetime.datetime.timetuple() to convert the datetime object to a tuple. Pass the tuple into calendar.timegm(tuple) to convert tuple to a timestamp.


how-to-convert-a-string-date-to-timestamp-in-python