This is a lot clearer then strtotime()
:
$start = DateTime::createFromFormat('Y-n-j', $_SESSION['year'].'-'.$_SESSION['month'].'-01');
$daysInMonth = $start->format('t');
$end = new DateTime("+{$daysInMonth} Days");
$interval = new DateInterval('P1D');
$period = new DatePeriod($start, $interval, $end);
foreach ($period as $day) {
if (in_array($day->format('D'), array('Sat', 'Sun'))) continue;
printf('<option value="%s"%s>%s %u</option>',
$day->format('j'),
($_SESSION['day'] == $day->format('j')) ? ' selected' : '',
$day->format('D'),
$day->format('j')
);
}
Demo