May-04-2021, 10:17 AM
(May-04-2021, 07:07 AM)menator01 Wrote: Not sure if this is what you want
import schedule, time from datetime import datetime def my_task(): custom_time = datetime(2021, 5, 1, 17, 30, 29, 431717) now = datetime.now() print(f'Custom Time:{custom_time} Current Time: {now} Time Difference: {custom_time-now}') schedule.every(1).minutes.do(my_task) while True: schedule.run_pending() time.sleep(1)
Output:Custom Time:2021-05-01 17:30:29.431717 Current Time: 2021-05-04 02:06:31.249154 Time Difference: -3 days, 15:23:58.182563 Custom Time:2021-05-01 17:30:29.431717 Current Time: 2021-05-04 02:07:31.312671 Time Difference: -3 days, 15:22:58.119046
Actually, user should be able to run following code when he wants. So it should be independent of the function defined and run with while loop.
print(f'Custom Time:{custom_time} Current Time: {now} Time Difference: {custom_time-now}')