PHP date("w", $timein) returns wrong value with a valid date -


this question has answer here:

i have function runs on server , want different output based on day of week, saturday , sunday should give weekend message , different weekdays.

$timein = date("y-m-d h:i:s"); $dw = date("d", $timein); $tm = date("e", $timein); echo "current date: ".$timein."<br>"; echo "day of week: ".$dw."<br>"; echo "timezone: ".$tm."<br>"; 

and output:

current date: 2015-05-15 06:07:12
day of week: wed
timezone: america/denver

we friday , expecting fri, using w instead of d getting 3 in results.

you need use strtotime function convert unix timestamp. update code into.

$dw = date("d", strtotime($timein)); $tm = date("e", strtotime($timein)); 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -