0

I have the following piece of code in php in order to redirect to different pages using the server's time. The problem is that server uses time 0-12 format and not 0-24. Any idea how to improve my code in order to work?

php?

  $timer=date('H:i:s');

  //redirect if hour between 8:00 to 21:00
  if(  ($timer > "08:00:00")  &&  ($timer < "21:00:00") ) {
    header('Location: index.php');
  }else{
    header('Location: logout.php');
  }
33528
  • 372
  • 6
  • 12
  • 30

1 Answers1

-1

date('H') is a 24 hour representation of the hour regradless of your timezone setting date('h') is a 12 hour representation, or date('g') if you don't want a leading zero

miknik
  • 5,748
  • 1
  • 10
  • 26