“datetime to string python” Code-Antworten

Python DateTime String

import datetime

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

Datetime to string PHP


<?php
$date = new DateTime('2000-01-01');
echo $date->format('Y-m-d H:i:s');
?>

Beautiful Baboon

datetime to string python

import datetime
t = datetime.datetime(2012, 2, 23, 0, 0)
t.strftime('%m/%d/%Y')
Juan David Morales Navarrete

Python vom Zeitstempel bis zur Schnur

from datetime import datetime

timestamp = 1545730073
dt_object = datetime.fromtimestamp(timestamp)

print("dt_object =", dt_object)
print("type(dt_object) =", type(dt_object))

# Output

dt_object = "2018-12-25 09:27:53"
type(dt_object) = <class 'datetime.datetime'>
Cippamilalippa

Python DateTime aus String

from datetime import datetime

datetime_object = datetime.strptime('Jun 1 2005  1:33PM', '%b %d %Y %I:%M%p')
Luoskate

datetime to string python

from datetime import datetime

now = datetime.now() # current date and time

year = now.strftime("%Y")
print("year:", year)

month = now.strftime("%m")
print("month:", month)

day = now.strftime("%d")
print("day:", day)

time = now.strftime("%H:%M:%S")
print("time:", time)

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

Ähnliche Antworten wie “datetime to string python”

Fragen ähnlich wie “datetime to string python”

Weitere verwandte Antworten zu “datetime to string python” auf Python

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen