PHP Check if current time is before specified time

前端 未结 9 2045
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-29 01:51

I need to check in PHP if the current time is before 2pm that day.

I\'ve done this with strtotime on dates before, however this time it\'s with a time o

9条回答
  •  醉梦人生
    2020-12-29 02:55

    You could just pass in the time

    if (time() < strtotime('2 pm')) {
       //not yet 2 pm
    }
    

    Or pass in the date explicitly as well

    if (time() < strtotime('2 pm ' . date('d-m-Y'))) {
       //not yet 2 pm
    }
    

提交回复
热议问题