Comparing times only, without dates?

后端 未结 8 1402
不知归路
不知归路 2021-01-31 16:30

I need to write a method that will check if Time.now is in between the open hours and the close hours of a shop.

The open and close hours are saved as a Tim

8条回答
  •  别跟我提以往
    2021-01-31 16:49

    You can compare the Time without a date part, for example, as follows:

    time1.utc.strftime( "%H%M%S%N" ) <= time2.utc.strftime( "%H%M%S%N" )
    

提交回复
热议问题