Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python datetime with day date suffix format

#!/usr/local/bin/python3
from datetime import date
today = date.today()
date_string = today.strftime('%A, %B #, %Y')
day = today.day

if (3 < day < 21) or (23 < day < 31):
	day = str(day) + 'th'
else:
  suffixes = {1: 'st', 2: 'nd', 3: 'rd'}
  day = str(day) + suffixes[day % 10]

print(date_string.replace('#', day), end='')
Comment

PREVIOUS NEXT
Code Example
Python :: Setting up WingIDE to debug Flask projects 
Python :: How to filter words that contain atleast 2 vowels from a series 
Python :: cronometro python tkinter 
Python :: python test class hashable 
Python :: python remove item from a list 
Python :: inherit functions from other classes 
Python :: python flask rest api 
Python :: list of dictionary values 
Python :: change a color on touch roblox 
Python :: django-admin startproject 
Python :: how to convert frame number in seconds python 
Python :: get single batch from torch data loader 
Python :: python wrapper function 
Python :: Add New Column to Pandas from Dictionary 
Python :: megre pandas in dictionary 
Python :: import in python 
Python :: python decomposition facteur premier 
Python :: Python Sort Lists 
Python :: datetime to epoch 
Python :: symbolic variables python 
Python :: python parse /etc/resolv.conf 
Python :: activate python venv in windows 
Python :: how to get the output in rupees in pandas 
Python :: pysimplegui start value 
Python :: python socket github 
Python :: python second interval 
Python :: how to add path to python in windows 
Python :: py environment variables register in flask 
Python :: figure in matplotlib 
Python :: User.objects.first() get specific id user in django 
ADD CONTENT
Topic
Content
Source link
Name
6+1 =