Remove-Th-From-Date
Sat 17 May 2025
title: "Remove th From Date" author: "Rj" date: 2019-04-20 description: "List Test" type: technical_note draft: false
from datetime import datetime
import re
content = 'Sunday, May 18th, 2019'
content
'Sunday, May 18th, 2019'
d = datetime.strptime(re.sub('(\d+)(st|nd|rd|th)', '\g<1>', content), '%A, %B %d, %Y')
d
datetime.datetime(2019, 5, 18, 0, 0)
Score: 5
Category: basics