Reputation: 1891
I am trying to return the day of the week based on the date that i pass into the date() function but it's not working. I have this:
echo date('N');
echo date('N', '2011-05-11');
Today is thursday, so these both return 4 no matter what I pass into it for a date. What am I doing wrong?
Upvotes: 0
Views: 818
Reputation: 2046
I think you need to use "D" instead of "N". N returns the index of the day and D returns the name.
Upvotes: 1
Reputation: 5565
echo date('N', strtotime('2011-05-11'));
date expects a timestamp as a second parameter, thats why you need to convert your string to a valid timestamp.
Upvotes: 1