T
T
The-TS2019-12-25 12:18:52
Python
The-TS, 2019-12-25 12:18:52

How to send a message at a specific time?

How to send a message from a bot at a specific time and date.
ps
I mean some
pss library Thanks
in advance)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
vsekov, 2019-12-25
@Pyhon3x

datetime library

from datetime import datetime

while True:
    now = datetime.now() # объект содержит дату и время

    dt_string = now.strftime("%d/%m/%Y %H:%M:%S")# строка, содержащая дату и время в формате dd/mm/YY H:M:S
    if(dt_string=="25/12/2019 09:29:00"): #Если строка с датой и временем равна строке с нужной датой и временем, то выводится дата и время
        print("date and time =", dt_string)	
        break

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question