Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python format datetime

# 10 July 2021, 10:54:27AM
datetime.strftime("%-d %B %Y, %I:%M:%S%p")
Comment

Python Datetime Format

# Python program to demonstrate strftime() function
from datetime import datetime as date

# Getting current date and time
now = date.now()
print("Without formatting", now)

# Example 1
s = now.strftime("%A %m %-Y")
print('
Example 1:', s)

# Example 2
s = now.strftime("%a %-m %y")
print('
Example 2:', s)

# Example 3
s = now.strftime("%-I %p %S")
print('
Example 3:', s)

# Example 4
s = now.strftime("%H:%M:%S")
print('
Example 4:', s)
Comment

PREVIOUS NEXT
Code Example
Python :: isnumeric python 
Python :: django urlpattern 
Python :: how to search a file in windows 10 using python 
Python :: stock market api python 
Python :: password generator in python 
Python :: check if anything in a list is in a string python 
Python :: python selenium headers 
Python :: create a list of a certain length python 
Python :: own labels for ticks matplotlib 
Python :: with open python 
Python :: how to display address in python 
Python :: Changing the number of ticks on a Matplotlib plot axis 
Python :: specify the number of decimals in a dataframe 
Python :: loop append to list python 
Python :: python Non-UTF-8 code starting with 
Python :: convert string to dictionary python 
Python :: tkinter menus 
Python :: compile python to pyc 
Python :: factorial program 
Python :: sum of any numbers in python 
Python :: time a line of code python 
Python :: pylint import error 
Python :: python list comprehension elif 
Python :: construct contingency table from pandas 
Python :: where are python libraries installed in windows 
Python :: python append a file and read 
Python :: how to change username of a bot using discord.py 
Python :: manipulate ip address in python 
Python :: django group by 
Python :: python subtract lists 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =