|
 |
|
มีเรื่องรบกวนให้ช่วยแนะนำนะครับ เรื่องการนับวันในแต่ละเดือน |
|
 |
|
|
 |
 |
|
<?php
function countDays($st,$end){
$st1 = strtotime($st);
$end1=strtotime($end);
$a = array_fill(0,6,0);
for($i = $st1;$i<=$end1;$i+= 3600*24) $a[date('w',$i)]++;
return $a;
}
$st = '2011-01-01';
$end = '2011-01-31';
$d = explode(',','sun,mon,tu,wed,th,fri,sat');
$a = countDays($st,$end);
echo 'between ',$st,' and ',$end,'<br>';
for($i=0;$i<7;$i++) echo $d[$i].'='.$a[$i].'<br>';
?>
http://web-programming-bookmark.blogspot.com/
|
 |
 |
 |
 |
Date :
2011-01-17 14:44:41 |
By :
num |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณมากๆเลยนะครับ ใช้งานได้ดีเลยทีเดียว ขอบคุณจริงๆครับ
Code (PHP)
<?php
function countDays($st,$end){
$st1 = strtotime($st);
$end1=strtotime($end);
$a = array_fill(0,6,0);
for($i = $st1;$i<=$end1;$i+= 3600*24) $a[date('w',$i)]++;
return $a;
}
$st = '2010-12-21';
$end = '2011-01-20';
$d = explode(',','sun,mon,tu,wed,th,fri,sat');
$a = countDays($st,$end);
echo 'between ',$st,' and ',$end,'<br>';
//for($i=0;$i<7;$i++) echo $d[$i].'='.$a[$i].'<br>';
echo $d[1].'='.$a[1].'<br>';
echo $d[4].'='.$a[4].'<br>';
$dMon=$a[1];
$dThu=$a[4];
$total=$dMon+$dThu;
echo $total;
?>
|
 |
 |
 |
 |
Date :
2011-01-17 15:40:00 |
By :
muaeenth99 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|