![](/img/trans.png)
[英]Show text if current time is between 9:00pm and 10:30pm on friday
[英]PHP: change time format 15:30:00 to 3:30PM
我有一些關於PHP和時間格式的問題。 我試圖使用date()函數更改時間。
$time = date('g:i a',$time);
但我得到的$time=15:30:30
15:30:30的結果是3:30 am
如果是下午,Ante meridiem會停留在AM事件上。
謝謝。
嘗試這樣的事情:
$time = date("g:i a", strtotime("15:30:00"));
如果從數據庫中取出我以前的代碼是
// get the Shift times
$shiftArray=array();
$num=0;
$getShiftTimes=mysqli_query($link,"SELECT * FROM shift");
while ($returnShiftTimes = mysqli_fetch_array($getShiftTimes)){
$shiftArray[$num][0]=$returnShiftTimes['shift_id'];
$shiftArray[$num][1]=$returnShiftTimes['start_time'];
$shiftArray[$num][2]=$returnShiftTimes['end_time'];
$num++;
}
$time = date_format(date_create($shiftArray[0][1]), 'g:i A');
從14:00:00起將返回下午2:00
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.