How to remove seconds from datetime?

前端 未结 10 1908
终归单人心
终归单人心 2021-02-20 13:02

I have the following date and I tried the following code,

df[\'start_date_time\'] = [\"2016-05-19 08:25:00\",\"2016-05-19 16:00:00\",\"2016-05-20 07:45:00\",\"20         


        
10条回答
  •  悲&欢浪女
    2021-02-20 13:59

    Here is a very simple way to remove seconds from datetime:

    from datetime import datetime 
    print(str(datetime.today())[:16])
    

    Output:

    2021-02-14 21:30
    

    It effectively transforms the timestamp into text and leaves only the first 16 symbols. Just don't lose yourself in all those brackets ;)

提交回复
热议问题