Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Current time in php like 5:00 pm?

Tags:

php

time

How to get Current time in php like 5:00 pm ? I have problem in getting time in php like 5:00 pm because I have to create a decision for example

<?php
$current_time = ("h:i a");
if($current_time > "5:00 pm"){
   echo 'Hide';
}else{
  echo 'show';
}
?>

I want to show the 'hide' text after 5:00 pm.

anyone knows?

Thanks for the help.

Very Much appreciated.

like image 449
devzone Avatar asked Dec 21 '25 07:12

devzone


1 Answers

Use the 24-hour-system and you won't have any problems: if(date('G') > 17)

G     24-hour format of an hour without leading zeros     0 through 23

like image 169
ThiefMaster Avatar answered Dec 23 '25 19:12

ThiefMaster