Reputation: 65
I am trying to build a function in php where it takes the user input date, which can be any date within pretty much the last 20 years. i tried to use the getdate() function in php to return to them the day of the week. here is what I have that isn't working.
$date="8/4/2010";//user input
$dateget=getdate($date);
echo $dateget; // i want an output like "monday" or "saturday"
when i run this code i get this error
A non well formed numeric value encountered (on the $dateget=getdate($date) line)
Thanks
Upvotes: 0
Views: 3748
Reputation: 2311
You need a timestamp for getdate function. So maybe strtotime function can help.
$date="8/4/2010";//user input
$dateget=getdate(strtotime($date));
echo $dateget['weekday'];
Upvotes: 3