What about using idate()? idate()
$integer = idate('w', $timestamp);
The date function can return this if you specify the format correctly:
$daynum = date("w", strtotime("wednesday"));
will return 0 for Sunday through to 6 for Saturday.
An alternative format is:
$daynum = date("N", strtotime("wednesday"));
which will return 1 for Monday through to 7 for Sunday (this is the ISO-8601 represensation).
$tm = localtime($timestamp, TRUE);
$dow = $tm['tm_wday'];
Where $dow
is the day of (the) week. Be aware of the herectic approach of localtime
, though (pun): Sunday is not the last day of the week, but the first (0).
$day_number = date('N', $date);
This will return a 1 for Monday to 7 for Sunday, for the date that is stored in $date. Omitting the second argument will cause date() to return the number for the current day.
Source: Stackoverflow.com