You can use:
$hour = 18;
echo date('h a', strtotime("$hour:00:00"));
Beacause date(format,time) expects a unix timestamp (seconds since the Unix Epoch, January 1 1970 00:00:00 GMT). Actually, using 18
will get '00:00:18' which is 12:18 am
Also, this will work:
$hour = 18;
echo date('h a', $hour*3600 ); // 1hr=3600sec
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…