I am using PHP version 5.0.5
I have a varaible ($DATE (date format yyyy-mm-dd)) that is being incremented to populate a table with each day of the month. I am then trying to get the day of week (preferably an integer) for each date in the month. I have tried both
$DOW = date("w", $Date)
and
$DOW = date("l", $Date)
Using October of this year however $DOW always returns either "3" or "Wednesday". I have checked and the varaible $Date is incrementing correctly. Here is the code snippet:
for ($num = 1; $num <= $Count; $num++) {
if($num < 10)
$SDPart = "0$num";
else
$SDPart = "$num";
$Date = "2009" . "-" . $SDMo . "-" . $SDPart;
$DOW = date("w", $Date);
Day of week
Moderator: General Moderators
-
Mark Baker
- Forum Regular
- Posts: 710
- Joined: Thu Oct 30, 2008 6:24 pm
Re: Day of week
date() requires a date/timestamp, not a formatted string, as the second parameter.
or
Code: Select all
$DOW = date("w", strtotime($Date));Code: Select all
$DOW = date("w", mktime(0,0,0,$SDMo,$SDPart,2009));Re: Day of week
Works perfectly. Thanks for the help!