Advertisement

TrimwebsolutionsTrimwebsolutions

Problem and Solutions

How to convert date string from database in python ?

By M.K. Verma · 3 May 2022

How to convert date string from database in python ?

the datetime.fromtimestamp function converts a date in posix format (a 32bit integer) to a local date format.

Return the local date and time corresponding to the POSIX timestamp, such as is returned by time.time(). If optional argument tz is None or not specified, the timestamp is converted to the platform’s local date and time, and the returned datetime object is naive.

If your date is in string format, use the function datetime.strptime(date_time_str, format)