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,137
  • 2
  • 22
  • 37

2 Answers2

1

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

if(strtotime(dateobject) > strtotime(dateobject)){
  //
}
Manwal
  • 23,450
  • 12
  • 63
  • 93
1

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

if(time() > strtotime(date('Y-m-d').' 10:30') {
    //...
}
Jazi
  • 6,569
  • 13
  • 60
  • 92