note 126432 added to ref.calendar

From: Date: Fri, 17 Sep 2021 19:16:29 +0000
Subject: note 126432 added to ref.calendar
Groups: php.notes 
Request: Send a blank email to php-notes+get-216968@lists.php.net to get a copy of this message
<?php class HijriCalendar { public static function monthName($i) // $i = 1..12 { static $month = array( "Moharram", "Safar", "Rabii-I", "Rabii-II", "Jumada-I", "Jumada-II", "Rajab", "Chaaban", "Ramadan", "Chawal", "Dhu-al-Qiida", "Dhu-al-Hijja" ); return $month[$i-1]; } public static function GregorianToHijri($time = null) { if ($time === null) $time = time(); $m = date('m', $time); $d = date('d', $time); $y = date('Y', $time); return HijriCalendar::JDToHijri( cal_to_jd(CAL_GREGORIAN, $m, $d, $y)); } public static function HijriToGregorian($m, $d, $y) { return jd_to_cal(CAL_GREGORIAN, HijriCalendar::HijriToJD($m, $d, $y)); } # Julian Day Count To Hijri public static function JDToHijri($jd) { $jd = $jd - 1948440 + 10632; $n = (int)(($jd - 1) / 10631); $jd = $jd - 10631 * $n + 354; $j = ((int)((10985 - $jd) / 5316)) * ((int)(50 * $jd / 17719)) + ((int)($jd / 5670)) * ((int)(43 * $jd / 15238)); $jd = $jd - ((int)((30 - $j) / 15)) * ((int)((17719 * $j) / 50)) - ((int)($j / 16)) * ((int)((15238 * $j) / 43)) + 29; $m = (int)(24 * $jd / 709); $d = $jd - (int)(709 * $m / 24); $y = 30*$n + $j - 30; return array($m, $d, $y); } # Hijri To Julian Day Count public static function HijriToJD($m, $d, $y) { return (int)((11 * $y + 3) / 30) + 354 * $y + 30 * $m - (int)(($m - 1) / 2) + $d + 1948440 - 385; } }; $hijri = HijriCalendar::GregorianToHijri( time() ); echo $hijri[1].'. '.HijriCalendar::monthName($hijri[0]).' '.$hijri[2]; ?> ---- Server IP: 45.112.84.4 Probable Submitter: 45.112.85.242 (proxied: 196.64.201.159) ---- Manual Page -- https://php.net/manual/en/ref.calendar.php Edit -- https://main.php.net/note/edit/126432 Del: integrated -- https://main.php.net/note/delete/126432/integrated Del: useless -- https://main.php.net/note/delete/126432/useless Del: bad code -- https://main.php.net/note/delete/126432/bad+code Del: spam -- https://main.php.net/note/delete/126432/spam Del: non-english -- https://main.php.net/note/delete/126432/non-english Del: in docs -- https://main.php.net/note/delete/126432/in+docs Del: other reasons-- https://main.php.net/note/delete/126432 Reject -- https://main.php.net/note/reject/126432 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#216968) next »