•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 397,838 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,604 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 232 | Replies: 0
![]() |
•
•
Join Date: Aug 2007
Posts: 154
Reputation:
Rep Power: 0
Solved Threads: 0
Hello everybody,
The following code I found from another place, and it was in Java Script, so I changed it to PHP, and I dont know:
1. how it is work ?
2. is it work at all?
3. need the algorithm and procedure of it...
Thanks...
The following code I found from another place, and it was in Java Script, so I changed it to PHP, and I dont know:
1. how it is work ?
2. is it work at all?
3. need the algorithm and procedure of it...
// PERSIAN_TO_JD -- Determine Julian day from Persian date
$PERSIAN_EPOCH = 1948320.5;
$PERSIAN_WEEKDAYS = Array("Yekshanbeh", "Doshanbeh",
"Seshhanbeh", "Chaharshanbeh",
"Panjshanbeh", "Jomeh", "Shanbeh");
function persian_to_jd($year, $month, $day)
{
$epbase = 0;
$epyear = 0;
$epbase = $year - (($year >= 0) ? 474 : 473);
$epyear = 474 + ($epbase % 2820);
return $day +
(($month <= 7) ?
(($month - 1) * 31) :
((($month - 1) * 30) + 6)
) +
floor((($epyear * 682) - 110) / 2816) +
($epyear - 1) * 365 +
floor($epbase / 2820) * 1029983 +
($PERSIAN_EPOCH - 1);
}
// JD_TO_PERSIAN -- Calculate Persian date from Julian day
function jd_to_persian($jd)
{
$year = 0;
$month = 0;
$day = 0;
$depoch = 0;
$cycle = 0;
$cyear = 0;
$ycycle = 0;
$aux1 = 0;
$aux2 = 0;
$yday = 0;
$jd = floor($jd) + 0.5;
$depoch = $jd - persian_to_jd(475, 1, 1);
$cycle = floor($depoch / 1029983);
$cyear = ($depoch % 1029983);
if ($cyear == 1029982) {
$ycycle = 2820;
} else {
$aux1 = floor($cyear / 366);
$aux2 = ($cyear % 366);
$ycycle = floor(((2134 * $aux1) + (2816 * $aux2) + 2815) / 1028522) +
$aux1 + 1;
}
$year = $ycycle + (2820 * $cycle) + 474;
if ($year <= 0) {
$year--;
}
$yday = ($jd - persian_to_jd($year, 1, 1)) + 1;
$month = ($yday <= 186) ? ceil($yday / 31) : ceil(($yday - 6) / 30);
$day = ($jd - persian_to_jd($year, $month, 1)) + 1;
return Array($year, $month, $day);
}
?>
Thanks...
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
Other Threads in the PHP Forum
- Previous Thread: i`m lost!!!
- Next Thread: Lamp installed ok .... but!


Linear Mode