2016-04-13 118 views
0

如何顯示當前日期爲默認值?我的頁面顯示「2006年1月」,因爲我使用另一個列出過去10年日期的代碼。以HTML格式建立當前日期

+0

@unex $ fromDate = date('Y-m'); $ toDate = date('Y-m'); – sheia

+1

你應該把這個帖子;)。 你應該試試'$ fromDate = new DateTime(); $ toDate = new DateTime();'。 – Unex

+0

@unex,非常感謝你:) – sheia

回答

0

您應該嘗試$fromDate = new DateTime(); $toDate = new DateTime();

+0

如果我會試圖做到這一點與if-else? like if($ i = 1;){ condition } else {$ i = 0;} – sheia

+0

你想做什麼?這是不明確的 – Unex

+0

我的意思是,如果當前月份是.04,那麼我怎樣才能通過if-else來構造它? – sheia

相關問題