note 84533 deleted from function.date by derick

From: Date: Sun, 26 Oct 2008 13:00:16 +0000
Subject: note 84533 deleted from function.date by derick
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-145771@lists.php.net to get a copy of this message
Note Submitter: Anonymous ---- to get the date of the monday from a week these function is useful: <?php /* Get First Calendar Week of Year x*/ function firstkw($jahr) { $erster = mktime(0,0,0,1,1,$jahr); $wtag = date('w',$erster); if ($wtag <= 4) { /** * Donnerstag oder kleiner: auf den Montag zurückrechnen. */ $montag = mktime(0,0,0,1,1-($wtag-1),$jahr); } else { /** * auf den Montag nach vorne rechnen. */ $montag = mktime(0,0,0,1,1+(7-$wtag+1),$jahr); } return $montag; } /*GET timestamp of monday of month x*/ function mondaykw($kwtime) { $firstmonday =$this->firstkw(date("Y", $kwtime)); $mon_monat = date('m',$firstmonday); $mon_jahr = date('Y',$firstmonday); $mon_tage = date('d',$firstmonday); $tage = (date("W", $kwtime)-1)*7; $mondaykw = mktime(0,0,0,$mon_monat,$mon_tage+$tage,$mon_jahr); return $mondaykw; } echo mondaykw(time()); //1215986400 ?>

« previous php.notes (#145771) next »