Answers for "python how to save datetime.date.today to a variable"

32

python current date

from datetime import date

today = date.today()
print("Today's date:", today)
Posted by: Guest on April-15-2020
2

python printing date

import datetime
print(datetime.datetime.now()) # --> (year, month, day, hour, minute, second, millisecond)
Posted by: Guest on October-03-2020
0

python run things at certain datetimes

import datetime as DT
import time

while True:
    now = DT.datetime.now()
    target = DT.datetime.combine(DT.date.today(), DT.time(hour=8))
    if target < now:
        target += DT.timedelta(days=1)

    time.sleep((target-now).total_seconds())
    # do something
Posted by: Guest on April-05-2020

Code answers related to "python how to save datetime.date.today to a variable"

Python Answers by Framework

Browse Popular Code Answers by Language