Python de fecha y hora
from datetime import datetime as d
date = d.now()
print(date.strftime("%Y-%m-%d %H:%M:%S"))
Majid Peidaei
from datetime import datetime as d
date = d.now()
print(date.strftime("%Y-%m-%d %H:%M:%S"))
import datetime
x = datetime.datetime(2018, 9, 15)
print(x.strftime("%b %d %Y %H:%M:%S"))
df['date_time']=pd.to_datetime(df['date_time'], format='%d-%m-%Y %H.%M.%S')
#fomrat given in code should match the format of the feature
#here--> df['date_time'][0]=10-03-2004 18.00.00
#watchout for the blanks '-' '.'
from datetime import datetime
custom_date_time = datetime(2021, 7, 23, 17, 30, 29, 431717)
print(custom_date_time)
# Output:
# 2021-07-23 17:30:29.431717
import datetime
now = datetime.datetime.now()
print(now.year, now.month, now.day, now.hour, now.minute, now.second)
import datetime as d
time = d.datetime.now()
time = time.strftime("%Y-%m-%d %H:%M:%S")
#year-#month-#date #hour:#minure:#second
print(time)