-2

I have this function that runs on the server and I want a different output based on the day of the week, Saturday and Sunday should give weekend message and different for the 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 the week: ".$dw."<br>";
echo "Timezone: ".$tm."<br>";

and this is the output:

Current Date: 2015-05-15 06:07:12
Day of the week: Wed
Timezone: America/Denver

We are Friday and I was expecting Fri, I was using w instead of D but I always was getting 3 in the results.

hg8
  • 1,082
  • 2
  • 15
  • 28
theshwaguy
  • 439
  • 1
  • 3
  • 14

1 Answers1

3

You need to use strtotime function to convert it into a Unix timestamp. Just update your code into.

$dw = date("D", strtotime($timein));
$tm = date("e", strtotime($timein));
Narendrasingh Sisodia
  • 21,247
  • 6
  • 47
  • 54