note 80846 added to function.mktime
| From: | Natefromnooberounodotcom at osu1 dot php dot net | Date: | Sun, 03 Feb 2008 03:45:23 +0000 |
| Subject: | note 80846 added to function.mktime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-135746@lists.php.net to get a copy of this message | ||
// How to get the UNIX Time for Sunday of any week of the year. I need it for consistant weekly
features regardless of the year.
// Current Week Number
$weeknumber = date("W");
// UNIX Time for Jan 1, (current year)
$firstweek = mktime(0,0,0,1,1,date("Y"));
// UNIX Time for the start of the current week (Usually not a Sunday)
$currentweek = $firstweek+($weeknumber*604800)-604800;
// Checks what day of the week it is, then adds a day until its Sunday
$sundaycheck = date("w",$currentweek);
do{
if($sundaycheck!=0){
$currentweek += 86400;
$sundaycheck = date("w",$currentweek);
}
}while($sundaycheck!=0);
echo date("l jS F, Y @ H:i:s a", $currentweek)."<br>";
// Will display the Sunday of the current week.
----
Server IP: 64.71.164.2
Probable Submitter: 76.88.101.191
----
Manual Page -- http://www.php.net/manual/en/function.mktime.php
Edit -- https://master.php.net/note/edit/80846
Del: integrated -- https://master.php.net/note/delete/80846/integrated
Del: useless -- https://master.php.net/note/delete/80846/useless
Del: bad code -- https://master.php.net/note/delete/80846/bad+code
Del: spam -- https://master.php.net/note/delete/80846/spam
Del: non-english -- https://master.php.net/note/delete/80846/non-english
Del: in docs -- https://master.php.net/note/delete/80846/in+docs
Del: other reasons-- https://master.php.net/note/delete/80846
Reject -- https://master.php.net/note/reject/80846
Search -- https://master.php.net/manage/user-notes.php