0

I know this question was probably asked, however i did not find the answer anywhere.

I would like to determine if the current time is before or after 10:30 AM with php. i found a long way to do it that involves a lot of time parsing. but i am sure there are better ways of doing it.

In this answer it show how to do it if the hour is a whole number (example 2PM)

if( 'now' is larger then 'a given time' ){

}
Community
  • 1
  • 1
Aryeh Armon
  • 2,080
  • 2
  • 21
  • 36

2 Answers2

1

Use strtotime(). But remember it accept date object.

if(strtotime(dateobject) > strtotime(dateobject)){
  //
}
Manwal
  • 22,994
  • 11
  • 59
  • 91
1

Use time(), date() and strtotime() functions:

if(time() > strtotime(date('Y-m-d').' 10:30') {
    //...
}
Jazi
  • 6,344
  • 12
  • 57
  • 89