note 77144 added to function.mktime
| From: | slerena at gmail dot com | Date: | Thu, 16 Aug 2007 19:28:10 +0000 |
| Subject: | note 77144 added to function.mktime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-129542@lists.php.net to get a copy of this message | ||
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>";
}
----
Server IP: 80.64.47.13
Probable Submitter: 87.217.45.253
----
Manual Page -- http://www.php.net/manual/en/function.mktime.php
Edit -- https://master.php.net/note/edit/77144
Del: integrated -- https://master.php.net/note/delete/77144/integrated
Del: useless -- https://master.php.net/note/delete/77144/useless
Del: bad code -- https://master.php.net/note/delete/77144/bad+code
Del: spam -- https://master.php.net/note/delete/77144/spam
Del: non-english -- https://master.php.net/note/delete/77144/non-english
Del: in docs -- https://master.php.net/note/delete/77144/in+docs
Del: other reasons-- https://master.php.net/note/delete/77144
Reject -- https://master.php.net/note/reject/77144
Search -- https://master.php.net/manage/user-notes.php