I'm trying to convert date (29/04/2017) to day in week but I get wrong value (Thursday, but need to be Saturday). I check the time of the server, all correct. my code:
$timestamp = strtotime("29/04/2017");
$day = date('l', $timestamp);
echo $day;
what can be the problem?
When you use slashes in your date, strtotime()
assumes MM/DD/YYYY. You either need to change the format of your date or use DateTime::createFromFormat()
to parse the date
$timestamp = strtotime("04/29/2017");
$day = date('l', $timestamp);
echo $day;
or
$date = DateTime::createFromFormat('d/m/Y, '29/04/2017);
$day = $date->format('l');
echo $day;