Answers for "datetime library python examples"

1

datetime library

#date and time in a mm/dd/yyyy hh:mm:ss format
from datetime import datetime
now = datetime.now()


print('%02d/%02d/%04d %02d:%02d:%02d' % (now.month, now.day, now.year, now.hour, now.minute, now.second))
Posted by: Guest on July-27-2021
2

python set a specific datetime

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
Posted by: Guest on June-27-2020
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

Code answers related to "datetime library python examples"

Python Answers by Framework

Browse Popular Code Answers by Language