note 77144 deleted from function.mktime by felipe

From: Date: Sun, 06 Jan 2008 12:07:05 +0000
Subject: note 77144 deleted from function.mktime by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-134857@lists.php.net to get a copy of this message
Note Submitter: slerena at gmail dot com ---- Thanks to all people that post it's code I've made two useful functions to check working days on each month, and render week times in a combo. function working_days (){ $date = date('Y-m-d'); $year = substr($date, 0,4); $month = substr($date, 5, 2); $day = substr($date, 8, 2); $d_daysinmonth = date('t', mktime(0,0,0,$month,1,$year)); // how many days in month $full_weeks = ceil ($d_daysinmonth / 7); $festive_days = floor(($d_daysinmonth / 7) * 2); $total_working_days = $d_daysinmonth - $festive_days; $total_working_hours = $total_working_days * 8; return $total_working_days; } function working_weeks_combo () { $date = date('Y-m-d'); $year = substr($date, 0,4); $month = substr($date, 5, 2); $day = substr($date, 8, 2); $d_daysinmonth = date('t', mktime(0,0,0,$month,1,$year)); // how many days in month $full_weeks = ceil ($d_daysinmonth / 7); $d_firstdow = date('w', mktime(0,0,0,$month,'1',$year)); // FIRST falls on what day of week (0-6) $ajuste = $d_firstdow -1; $new_date = date('Y-m-d', strtotime("$year-$month-01 - $ajuste days")); echo '<select name="working_week">'; for ($ax=0; $ax < $full_weeks; $ax++){ echo "<option>".date('Y-m-d', strtotime($new_date. "+ $ax week")); } echo "</select>"; }

« previous php.notes (#134857) next »