Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

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)
Source by softhunt.net #
 
PREVIOUS NEXT
Tagged: #Python #Datetime #Format
ADD COMMENT
Topic
Name
1+8 =