2011-08-08 49 views
0

我想在php中建立一個函數,它需要用戶輸入日期,它可以是過去20年內的任何日期。我試圖在php中使用getdate()函數在一週中的某一天返回給他們。 這是我有沒有工作。用php getdate()函數尋找工作日

$date="8/4/2010";//user input 
$dateget=getdate($date); 
echo $dateget; // i want an output like "monday" or "saturday" 

當我運行這段代碼我得到這個錯誤

A non well formed numeric value encountered (on the $dateget=getdate($date) line) 

感謝

回答

3

您需要getdate function時間戳。所以也許strtotime函數可以提供幫助。

$date="8/4/2010";//user input 
$dateget=getdate(strtotime($date)); 
echo $dateget['weekday']; 
+0

好的,我能夠從星期一得到這樣的工作。謝謝!!! – chris