Good time!

such a problem, I want to get the number of the day of the week by date, but for some reason I constantly get 4 - no matter what date I put, here’s the script

echo date("w",'2016-03-11 15:02:00')."<br>"; echo date("w",'2016-03-12 15:02:00')."<br>"; echo date("w",'2016-03-13 15:02:00')."<br>"; 

gives 4 4 4, maybe I did not understand correctly how the date function works? Why do I always get the 4th day?

  • four
    Your second parameter is not a timestamp format, but a string. Use this as date ('w', strtotime ('2016-03-11 15:00:03')). ( php.net/manual/en/function.date.php ) - Daniel Protopopov
  • one
    @DanielProtopopov can not be shy and write it as an answer. Well, or find a duplicate, if such a question already existed - Ipatiev
  • @ Ipatiev yes, I agree, a little backtrack from the habit of giving suggestive, not complete answers :) - Daniel Protopopov

0