WCM - Das österreichische Computer Magazin Forenübersicht
 

Zurück   WCM Forum > Rat & Tat > Programmierung

Programmierung Rat & Tat für Programmierer

Microsoft KARRIERECAMPUS

 
 
Themen-Optionen Ansicht
Alt 07.02.2006, 18:53   #2
jak
Inventar
 
Registriert seit: 13.06.2001
Beiträge: 1.830


Standard

Kenne keine solche Funktion, kann man aber leicht selbst schreiben:

Code:
function getDaysPerMonth($year, $month){
  $daysPerMonth = Array(0,31,28,31,30,31,30,31,31,30,31,30,31);
  $days = 0;
  $isLeapYear = false;
  if(($month < 1) || ($month > 12)) return false;
  if($month == 2) {
    //every 4th year is a leap year, years like 100, 200, 300, 1900 are not,
    // 400, 800, 2000 are leap years.
    if($year % 100 == 0){
      $isLeapYear = ((($year/ 100) % 4) == 0);
    } else {
      $isLeapYear = (($year % 4) == 0)
    }
  }
  if($month == 2 && $isLeapYear){
    $days = 29;
  } else {
    $days = $daysPerMonth($month);
  }
  $daysInMonth = Array();
  for($i = 0; $i < $days; $i++) $daysInMonth[] = $i
  return $daysInMonth
}
Wenn dich die Wochentage interessieren (Montag, Dienstag etc.) würde ich mir den ersten Wochentag über:
Code:
$startday = date('w',strtotime($year.($month < 10 ? '0' : '').$month.'01'));
holen und den Rest dann mit switch ($i+$startday % 7){case 0: ....} machen.

Siehe http://at.php.net/manual/de/function.strtotime.php und http://at.php.net/manual/de/function.date.php

jak
____________________________________
Join the DNRC | Godwin\'s Law (thx@stona)
Documentation is like sex: If it\'s good, it\'s very, very good. If it\'s bad, it\'s better than nothing.
\"In theory, theory and practice are the same. In practice, they are not\" (Lawrence Berra)
jak ist offline   Mit Zitat antworten
 


Aktive Benutzer in diesem Thema: 1 (Registrierte Benutzer: 0, Gäste: 1)
 

Forumregeln
Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.

Gehe zu


Alle Zeitangaben in WEZ +2. Es ist jetzt 01:18 Uhr.


Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Forum SEO by Zoints
© 2009 FSL Verlag