How can I check if the current time is between in a time frame?

后端 未结 4 517
猫巷女王i
猫巷女王i 2020-12-02 15:50

I have a service that user can configure to run during \"off-peak\" hours. They have the ability to set the time frame that the service can run.

For Example:

4条回答
  •  有刺的猬
    2020-12-02 16:42

    I'm assuming you are saving the start and end times in the applications configuration file, so all you basically have to do is have your application set a flag to "on" when the "start time" occurs and set it to "off" when the stop time occurs.

    That way you don't have to be constantly checking if "now" is "between start and end" times.

提交回复
热议问题