|
|
|
ใครพอเข้าใจ ช่วยแปลงโค้ดjava ให้เป็นphpให้หน่อยนะคะ |
|
|
|
|
|
|
|
Code (PHP)
function javatophp($st,$end)
{
$sst = explode("/",$st);
$sen =explode("/",$end);
$s0 = $sst ['0']; // month before
$s1 = $sst ['1']; // $day before
$s2 = $sst ['2']; // year before
$e0 = $sen ['0']; // month after
$e1 = $sen ['1']; // $day after
$e2 = $sen ['2']; // year after
//################
/*<!-- Start Algorithm
* verify $day each month
*
*/
if(($s0==1)||($s0==3)||($s0==7)||($s0==8)||($s0==10)||($s0==12)||($s0==5))
{
$day = 31;
}
else if (($s0==4)||($s0==6)||($s0==9)||($s0==8)||($s0==11))
{
$day = 30;
}
else if (($s2==2012)||($s2==2016)||($s2==2020)||($s2==2024)||($s2==2028)||($s2==2022)||($s2==2026))
{
if($s0==2)
{
$day = 29;
}
}
else
{
$day = 28;
}
if($e2 > $s2)
{ // verify year
$d = ($day - $s1)+$e1;
}
else
{
if($e0 > $s0)
{
$d = ($day - $s1)+$e1;
} //verify between month
else
{
$d = $e1 - $s1;
} // in month
}
//<--End Algorithm -->
//#################
return $d;
}
echo javatophp("2/29/2012","4/25/2012") // year not more than 2026 only
|
|
|
|
|
Date :
2012-02-18 18:17:47 |
By :
mangkunzo |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณนะคะ
|
|
|
|
|
Date :
2012-02-18 22:20:37 |
By :
konsand |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|