Time Import # convert formatted time stamp into DEF str_to_timestamp (str_time = None, the format = '% Y-M-% D%% H:% M:% S'): IF str_time: time_tuple = the time.strptime (str_time , format) # is converted into the formatted time neuron progenitor result = time.mktime (time_tuple) # converting the time stamp tuples to return int (Result) return int (the time.time ()) Print (str_to_timestamp ( '2019- 07:01:46 04-27 ')) Print (str_to_timestamp ()) # 1,556,349,904 # convert a timestamp into formatted def timestamp_to_str (timestamp = None, format ='% Y-% m-% d% H:% M :% S '): IF timestamp: time_tuple time.localtime = (timestamp) time is converted into time stamp # neuron progenitor result = time.strftime (format, time_tuple) # time to convert into formatted time neuron progenitor return result the else: return time.strptime(format) print(timestamp_to_str(1556348505)) #2019-04-27 15:01:45