如何在php中檢查時間是否可以說12,如果是,執行一些代碼。 這是我迄今爲止。php日期時間運算符
我希望代碼在特定時間進行,並且只在當時每天進行。
if (date('H') == 20)
{
//code to be carried out
CODE
CODE
CODE
echo ("lol");
}
然而,無論時間如何,cocde似乎都在運行!
即使時間不是晚上8點,程序也會每次回覆lol。
任何幫助表示讚賞感謝
如何在php中檢查時間是否可以說12,如果是,執行一些代碼。 這是我迄今爲止。php日期時間運算符
我希望代碼在特定時間進行,並且只在當時每天進行。
if (date('H') == 20)
{
//code to be carried out
CODE
CODE
CODE
echo ("lol");
}
然而,無論時間如何,cocde似乎都在運行!
即使時間不是晚上8點,程序也會每次回覆lol。
任何幫助表示讚賞感謝
它不是呼應了在我的測試:
g 12-hour format of an hour without leading zeros 1 through 12
G 24-hour format of an hour without leading zeros 0 through 23
h 12-hour format of an hour with leading zeros 01 through 12
H 24-hour format of an hour with leading zeros 00 through 23
您的代碼,除非這是不是---嘗試和複製應該工作原始來源
'echo date('H')'看看它給你什麼時間。 – Norse
@Norse H =一小時24小時格式,前導零00到23 –
@LawrenceCherone啊,不知道。編輯我的迴應。 – Norse