0

過去20年以内の任意の日付である可能性がある、ユーザー入力日付を取る関数をphpで構築しようとしています。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)

ありがとう

4

1 に答える 1

3

getdate functionにはタイムスタンプが必要です。したがって、おそらく strtotime 関数が役立ちます。

$date="8/4/2010";//user input
$dateget=getdate(strtotime($date));
echo $dateget['weekday'];
于 2011-08-08T16:59:54.010 に答える