2021年4月10日星期六

Extracting year, month, day, hour and minute from the current datetime

I need to extract year, month, day, hour and possible also minutes from the current datetime:

import datetime  from datetime import datetime    now = datetime.now()   date_t = now.strftime("%d/%m/%Y %H:%M")  

trying

    date_t.day()      date_t.month()      date_t.year()      date_t.hour()      date_t.minute()  

It does not work as I have an error: AttributeError: 'str' object has no attribute 'year'. I hope you can help

https://stackoverflow.com/questions/67040825/extracting-year-month-day-hour-and-minute-from-the-current-datetime April 11, 2021 at 10:03AM

没有评论:

发表评论