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 :: python max absolute value 
Python :: python bisection method 
Python :: python push into array if not exists 
Python :: Removing punctuation in Python 
Python :: module turtle has no forward member 
Python :: python write yaml 
Python :: random chiece python 
Python :: numpy style docstrings 
Python :: print(DATA.popitem()) 
Python :: import tknter 
Python :: changing instance through dict changes all instances 
Python :: how to run pytest and enter console on failure 
Python :: folium python map in full screen 
Python :: python wget anaconda 
Python :: flask app example 
Python :: to_dataframe pandas 
Python :: python sympy solve equation equal to 0 
Python :: ellipsis in python as index 
Python :: get most repeated instance in a queryset django 
Python :: pyqt5 window size 
Python :: python create hash from string 
Python :: import c# dll in python 
Python :: position in alphabet python 
Python :: pythons os module choose random file 
Python :: vertical line in matplotlib 
Python :: image from wikipedia module in python 
Python :: lambda with two columns pandas 
Python :: How to efficiently find the first index in an array of distinct numbers that is equal to the value at that index? 
Python :: how to pronounce aesthetic 
Python :: get all indices of a value in list python 
ADD CONTENT
Topic
Content
Source link
Name
6+8 =