2023-05-05T194705192394+0530 format date in python 5th May 2023
You can format the date in Python using the strftime() method. Here's an example:
import datetime
date_str = '2023-05-05T19:47:05.192394+05:30'
date_obj = datetime.datetime.fromisoformat(date_str)
formatted_date = date_obj.strftime('%d %B %Y')
print(formatted_date)
Output:
05 May 2023
Explanation:
- The
fromisoformat()method is used to convert the date string to a datetime object. - The
strftime()method is used to format the datetime object into the desired format, which is'%d %B %Y'in this case.%drepresents the day of the month,%Brepresents the full month name, and%Yrepresents the year in four digits
原文地址: https://www.cveoy.top/t/topic/eC9D 著作权归作者所有。请勿转载和采集!