Answers for "how to change the starting date in dt python"

8

datetime year python

import datetime
now = datetime.datetime.now()
print(now.year, now.month, now.day, now.hour, now.minute, now.second)
Posted by: Guest on May-12-2020
1

date.month date time

import datetime
dt = datetime.datetime.today()
print dt.year
# Output: 2016

print dt.month
# Output: 8

print dt.day
# Output: 22
Posted by: Guest on July-04-2020
1

how to add two different times in python

import datetime as dt
t1 = dt.datetime.strptime('12:00:00', '%H:%M:%S')
t2 = dt.datetime.strptime('02:00:00', '%H:%M:%S')
time_zero = dt.datetime.strptime('00:00:00', '%H:%M:%S')
print((t1 - time_zero + t2).time())
Posted by: Guest on April-29-2020

Code answers related to "how to change the starting date in dt python"

Python Answers by Framework

Browse Popular Code Answers by Language