Board index   FAQ   Search  
Register  Login
Board index PHP PHP General

Today in Jewish date

General discussions related to php

Moderators: macek, egami, gesf

Today in Jewish date

Postby henris » Wed Jul 18, 2012 12:08 am

Hello,
I am completely PHP illiterate, but maybe you can help. I want to have today date displayed in Jewish date.
I have found the code hereunder which could function for a date in (month,day,year) [line 25] how to modify it for the actual system date (today) ? (also how to correct the 'split' error)

Thanks
Henri

Code: Select all
<?php
function isJewishLeapYear($year) {
  if ($year % 19 == 0 || $year % 19 == 3 || $year % 19 == 6 ||
      $year % 19 == 8 || $year % 19 == 11 || $year % 19 == 14 ||
      $year % 19 == 17)
    return true;
  else
    return false;
}

function getJewishMonthName($jewishMonth, $jewishYear) {
  $jewishMonthNamesLeap = array("Tishri", "Heshvan", "Kislev", "Tevet",
                                "Shevat", "Adar I", "Adar II", "Nisan",
                                "Iyar", "Sivan", "Tammuz", "Av", "Elul");
  $jewishMonthNamesNonLeap = array("Tishri", "Heshvan", "Kislev", "Tevet",
                                   "Shevat", "Adar", "", "Nisan",
                                   "Iyar", "Sivan", "Tammuz", "Av", "Elul");
  if (isJewishLeapYear($jewishYear))
    return $jewishMonthNamesLeap[$jewishMonth-1];
  else
    return $jewishMonthNamesNonLeap[$jewishMonth-1];
}

$jdNumber = gregoriantojd(5, 21, 1993);
$jewishDate = jdtojewish($jdNumber);
list($jewishMonth, $jewishDay, $jewishYear) = split('/', $jewishDate);
$jewishMonthName = getJewishMonthName($jewishMonth, $jewishYear);
echo "<p>The 21 May 1993 is the $jewishDay $jewishMonthName $jewishYear</p>\n";
?>
henris
New php-forum User
New php-forum User
 
Posts: 3
Joined: Tue Jul 17, 2012 11:54 pm

Return to PHP General

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.