<?php
//判斷兩個日期是否在同一區間
function This_frame($in_date)
{
$ck_date = strtotime($in_date);
$year = date("Y",$ck_date);
//echo "0:$ck_date <br /><br />";
$range_in = null;
//控制區間範圍
$range = 3;
$fin = ceil(12/$range); //無條件+1
for ($i=0;$i<$fin;$i++)
{
// echo "$i<br />";
//計算月份區間
$mon_st = 1 + ($range*$i);
$date_st = strtotime (date( "Y-m-d", mktime (0,0,0,$mon_st ,1, date($year))));
// echo "$i:$date_st <br />";
$mon_en = 1 + ($range*($i+1));
$date_en = strtotime (date( "Y-m-d", mktime (0,0,0,$mon_en ,1, date($year))));
// echo "$i:$date_en <br />";
// echo "$mon_st~$mon_en <br />";
// echo date("Y-m-d",$date_st) . "~" . date("Y-m-d",$date_en) ." <br /><br />";
if($ck_date >= $date_st && $ck_date < $date_en) {$range_in = $i;}
}
//echo "$range_in:";
return $range_in+1;
}
function Show_date_frame($in_date)
{
$ck_date = strtotime($in_date);
$year = date("Y",$ck_date);
//echo "0:$ck_date <br /><br />";
$range_in = null;
//控制區間範圍
$range = 3;
$fin = ceil(12/$range); //無條件+1
for ($i=0;$i<$fin;$i++)
{
// echo "$i<br />";
//計算月份區間
$mon_st = 1 + ($range*$i);
$st = date( "Y-m-d", mktime (0,0,0,$mon_st ,1, date($year)));
$date_st = strtotime (date( "Y-m-d", mktime (0,0,0,$mon_st ,1, date($year))));
// echo "$i:$date_st <br />";
$mon_en = 1 + ($range*($i+1));
$en = date( "Y-m-d", mktime (0,0,0,$mon_en ,1, date($year)));
$date_en = strtotime (date( "Y-m-d", mktime (0,0,0,$mon_en ,1, date($year))));
if($ck_date >= $date_st && $ck_date < $date_en) {
$result = array (
"st" => $st,
"en" => $en
);
}
}
return $result;
}
function Show_all_frame($in_date)
{
$ck_date = strtotime($in_date);
$year = date("Y",$ck_date);
//控制區間範圍
$range = 3;
$fin = ceil(12/$range); //無條件+1
$i = $in_range-1;
for ($i=0;$i<$fin;$i++)
{
$mon_st = 1 + ($range*$i);
$st = date( "Y-m-d", mktime (0,0,0,$mon_st ,1, date($year)));
// echo "$i:$date_st <br />";
$mon_en = 1 + ($range*($i+1));
$en = date( "Y-m-d", mktime (0,0,0,$mon_en ,1, date($year)));
$result[$i+1] = array (
"st" => $st,
"en" => $en
);
}
return $result;
}
//讀月
function This_month($in_date)
{
$ck_date = strtotime($in_date);
$mon = date("n",$ck_date);
return $mon;
}
//讀年
function This_year($in_date)
{
$ck_date = strtotime($in_date);
$year = date("Y",$ck_date);
return $year;
}
//判斷兩個日期是否在同一區間
function This_frame($in_date)
{
$ck_date = strtotime($in_date);
$year = date("Y",$ck_date);
//echo "0:$ck_date <br /><br />";
$range_in = null;
//控制區間範圍
$range = 3;
$fin = ceil(12/$range); //無條件+1
for ($i=0;$i<$fin;$i++)
{
// echo "$i<br />";
//計算月份區間
$mon_st = 1 + ($range*$i);
$date_st = strtotime (date( "Y-m-d", mktime (0,0,0,$mon_st ,1, date($year))));
// echo "$i:$date_st <br />";
$mon_en = 1 + ($range*($i+1));
$date_en = strtotime (date( "Y-m-d", mktime (0,0,0,$mon_en ,1, date($year))));
// echo "$i:$date_en <br />";
// echo "$mon_st~$mon_en <br />";
// echo date("Y-m-d",$date_st) . "~" . date("Y-m-d",$date_en) ." <br /><br />";
if($ck_date >= $date_st && $ck_date < $date_en) {$range_in = $i;}
}
//echo "$range_in:";
return $range_in+1;
}
function Show_date_frame($in_date)
{
$ck_date = strtotime($in_date);
$year = date("Y",$ck_date);
//echo "0:$ck_date <br /><br />";
$range_in = null;
//控制區間範圍
$range = 3;
$fin = ceil(12/$range); //無條件+1
for ($i=0;$i<$fin;$i++)
{
// echo "$i<br />";
//計算月份區間
$mon_st = 1 + ($range*$i);
$st = date( "Y-m-d", mktime (0,0,0,$mon_st ,1, date($year)));
$date_st = strtotime (date( "Y-m-d", mktime (0,0,0,$mon_st ,1, date($year))));
// echo "$i:$date_st <br />";
$mon_en = 1 + ($range*($i+1));
$en = date( "Y-m-d", mktime (0,0,0,$mon_en ,1, date($year)));
$date_en = strtotime (date( "Y-m-d", mktime (0,0,0,$mon_en ,1, date($year))));
if($ck_date >= $date_st && $ck_date < $date_en) {
$result = array (
"st" => $st,
"en" => $en
);
}
}
return $result;
}
function Show_all_frame($in_date)
{
$ck_date = strtotime($in_date);
$year = date("Y",$ck_date);
//控制區間範圍
$range = 3;
$fin = ceil(12/$range); //無條件+1
$i = $in_range-1;
for ($i=0;$i<$fin;$i++)
{
$mon_st = 1 + ($range*$i);
$st = date( "Y-m-d", mktime (0,0,0,$mon_st ,1, date($year)));
// echo "$i:$date_st <br />";
$mon_en = 1 + ($range*($i+1));
$en = date( "Y-m-d", mktime (0,0,0,$mon_en ,1, date($year)));
$result[$i+1] = array (
"st" => $st,
"en" => $en
);
}
return $result;
}
function This_month($in_date)
{
$ck_date = strtotime($in_date);
$mon = date("n",$ck_date);
return $mon;
}
function This_year($in_date)
{
$ck_date = strtotime($in_date);
$year = date("Y",$ck_date);
return $year;
}
留言列表