return day of week when timestamp passed into date function php
I am trying to re开发者_如何转开发turn 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?
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.
I think you need to use "D" instead of "N". N returns the index of the day and D returns the name.
精彩评论