note 33936 added to function.strtotime
| From: | php_net at evgeny dot ee | Date: | Fri, 11 Jul 2003 14:01:47 +0000 |
| Subject: | note 33936 added to function.strtotime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-51911@lists.php.net to get a copy of this message | ||
Two usefull functions, if you want to built your own calendar.
################
# Returns date of the Monday for given number of week(1..53) and year.
# Output is in date-format.
function get_monday($week, $year=""){
$first_date = strtotime("1 january ".($year ? $year : date("Y")));
if(date("D", $first_date)=="Mon") {
$monday = $first_date;
} else {
$monday = strtotime("next Monday", $first_date)-604800;
}
$plus_week = "+".($week-1)." week";
return strtotime($plus_week, $monday);
}
###############
# analog to get_monday(), but returns Sunday:
function get_sunday($week, $year=""){
return get_monday($week, $year)+604799;
}
###############
# Example:
echo date("d.m.Y", get_monday(42, 2003)); // output is "13.10.2003"
----
Manual Page -- http://www.php.net/manual/en/function.strtotime.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+33936
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+33936&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+33936&report=yes