2012-05-08 51 views
-2

我正在開發一個使用PHP(Codeigniter)的Web應用程序。 當用戶在應用程序中請求某個資源時,我需要檢查當前日期是在本月25日之前還是之後。我怎樣才能做到這一點?我不知道怎麼做。檢查日期是在同一個月的某個日期之前還是之後

+0

目前已經很多關於PHP日期的問題。如果你谷歌它,你會在前兩頁得到答案。 – Robik

+0

@Donut仇恨會討厭,這個網站是爲了幫助不討厭 – Petah

+0

@Petah這個網站是不是爲重複。 http://stackoverflow.com/faq#close – Robik

回答

3

這應該這樣做...

if (date('j') < 25) { 
    // date before 25th 
} 
2

您可以使用date功能與j格式類型爲

if (date('j') > 25) { 
    // It is after the 25th 
} elseif (date('j') < 25) { 
    // It is before the 25th 
} else { 
    // It is the 25th 
} 

http://php.net/manual/en/function.date.php更多信息

相關問題