“datetime ke string python” Kode Jawaban

string datetime python

import datetime

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

Datetime ke string php


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

Beautiful Baboon

datetime ke string python

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

Python dari cap waktu ke string

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

datetime python dari string

from datetime import datetime

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

datetime ke 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

Jawaban yang mirip dengan “datetime ke string python”

Pertanyaan yang mirip dengan “datetime ke string python”

Lebih banyak jawaban terkait untuk “datetime ke string python” di Python

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya