|
|
|
CODE DATE $nextWeek = time() + (7 * 24 * 60 * 60); |
|
|
|
|
|
|
|
Code (PHP)
<?php
/*$date=2009-12-8;
for ($i=1; $i<=52; $i++) {
$nextWeek = time() + (7 * 24 * 60 * 60);
// 7 days; 24 hours; 60 mins; 60secs
echo 'Now: '. date('Y-m-d') ."\n";
echo "$i"."/";
$daynew=date('$date', $nextWeek);
echo date('1-1-2009',$ts_start); //start date
echo '<br>';
echo date('m-d-Y',$ts_end); //end date
echo 'Next Week: '. $daynew."\n";
echo"</br>";*/
//}
// or using strtotime():
//echo 'Next Week: '. date('Y-m-d', strtotime('+1 week')) ."\n";
$now = time();
$num = date("w");
if ($num == 0)
{ $sub = 6; }
else { $sub = ($num-1); }
$WeekMon = mktime(0, 0, 0, date("m", $now) , date("d", $now)-$sub, date("Y", $now)); //monday week begin calculation
$todayh = getdate($WeekMon); //monday week begin reconvert
$d = $todayh[mday];
$m = $todayh[mon];
$y = $todayh[year];
echo "$d-$m-$y"; //getdate converted day
?>
<?php
$weeks_in_year = strftime("%W",strtotime("12/31/2009"));
echo "$weeks_in_year"; echo "</br>";
?>
<?php
function getMondays($year) {
$newyear = $year;
$week = 0;
$day = 0;
$mo = 1;
$mondays = array();
$i = 1;
while ($week != 1) {
$day++;
$week = date("w", mktime(0, 0, 0, $mo,$day, $year));
}
array_push($mondays,date("r", mktime(0, 0, 0, $mo,$day, $year)));
while ($newyear == $year) {
$test = strtotime(date("r", mktime(0, 0, 0, $mo,$day, $year)) . "+" . $i . " week");
$i++;
if ($year == date("Y",$test)) {
array_push($mondays,date("r", $test));
}
$newyear = date("Y",$test);
}
return $mondays;
}
$Data=getMondays('2009');
for($i=0; $i<Count($Data); $i++) {
echo $i+1 ," = " , substr("$Data[$i]", 0, -14) ,"<br>";
}
// print_r(getMondays('2009'));
?>
Tag : - - - -
|
|
|
|
|
|
Date :
2009-12-08 23:20:06 |
By :
avaegee |
View :
1147 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
อะไรหรอครับ ? มาบอกหรือมาถามครับ
|
|
|
|
|
Date :
2009-12-08 23:28:37 |
By :
panyapol |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|