开发者

return day of week when timestamp passed into date function php

开发者 https://www.devze.com 2023-03-05 23:06 出处:网络
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:

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消