PHP date("w", $timein) returns wrong value with a valid date -
this question has answer here:
- convert 1 date format in php 12 answers
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
Post a Comment