![]() |
![]() |
|
|
|||||||
| Programmierung Rat & Tat für Programmierer |
![]() |
|
|
Themen-Optionen | Ansicht |
|
|
#1 |
|
Inventar
![]() Registriert seit: 08.11.2000
Alter: 42
Beiträge: 1.524
|
hi,
ich suche eine php funktion die folgendes kann: eingabe: jahr, monat rückgabe: alle tage des monats (eben 30 od. 31 oder eben spez. auch für den februar) in einem array
____________________________________
H.E.W.L.E.T.T.: Hydraulic Electronic Worker Limited to Exploration and Terran Troubleshooting |
|
|
|
|
|
#2 |
|
Inventar
![]() Registriert seit: 13.06.2001
Beiträge: 1.830
|
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
}
Code:
$startday = date('w',strtotime($year.($month < 10 ? '0' : '').$month.'01'));
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) |
|
|
|
|
|
#3 |
|
Inventar
![]() Registriert seit: 08.11.2000
Alter: 42
Beiträge: 1.524
|
thx
____________________________________
H.E.W.L.E.T.T.: Hydraulic Electronic Worker Limited to Exploration and Terran Troubleshooting |
|
|
|
|
|
#4 |
|
Master
![]() Registriert seit: 13.08.2003
Beiträge: 624
|
Die Anzahl der Tage kannst du grundsätzlich einfach ermitteln.
laut http://de.php.net/manual/de/function.date.php geht das mit date('t',Datum) mfg Thomas |
|
|
|
![]() |
| Aktive Benutzer in diesem Thema: 1 (Registrierte Benutzer: 0, Gäste: 1) | |
|
|