“Python Format DateTime” Réponses codées

chaîne Python Datetime

import datetime

today = datetime.datetime.now()
date_time = today.strftime("%m/%d/%Y, %H:%M:%S")
print("date and time:",date_time)
marcofaga

Python Format DateTime

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

DateTime Python

from datetime import datetime as d
date = d.now()
print(date.strftime("%Y-%m-%d %H:%M:%S"))
Majid Peidaei

Format Python DateTime

# 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('\nExample 1:', s)

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

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

# Example 4
s = now.strftime("%H:%M:%S")
print('\nExample 4:', s)
Outrageous Ostrich

Datetime Year Python

import datetime
now = datetime.datetime.now()
print(now.year, now.month, now.day, now.hour, now.minute, now.second)
miletoo

Python Imprimer Datetime

import datetime
print("Now:", datetime.datetime.now())
Awful Antelope

Réponses similaires à “Python Format DateTime”

Questions similaires à “Python Format DateTime”

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code