Non-Gregorian Dates and Calendars

You are viewing a wiki page. You are welcome to join the group and then edit it. Be bold!

There have been periodic requests to add support for non-Gregorian dates and calendars to Drupal. (See and, for example) I've been doing a bit of thinking about this and have concluded that it could be possible but would require a big effort. The basic approach I'm thinking of now would be to create a wrapper class for date and calendar handling that will default to use Gregorian dates but would make it possible to plug in others. We could also look at ways to use the Drupal hook system, but in this case a wrapper class might work better.

So this wiki page is a place where anyone interested can start to post ideas and code. We need:

Aspects of other calendars that might be different

  • The number of days in a month
  • The number of months in a year??
  • The number of days in a year
  • The number of days in a week??
  • Day names -- can we use translation system if the number of days in a week is always 7??
  • Month names -- can we use translation system if the number of months in a year is always 12??
  • First day of week
  • First day of year
  • Uses daylight savings time?
  • Has timezones and needs timezone conversions?
  • Has leap year, leap month, leap day, etc.
  • Date formats, alternative ways to display a given date
  • Abbreviations for day and month names (hard to do with current translation system)
  • Date storage -- store as timestamp? store as datetime? other? How big does the field need to be?

List of Calendars

List of some of the calendars that are important to people now using Drupal who can make some kind of contribution to this effort.

How to Integrate

My initial thought is that we have a subdirectory called "calendars" under the module's directory, with several .inc files in it, one for each type of calendar, e.g.,, ...etc. Of course, all this needs to be done for dates (list all calendars, enable selected calendards only, convert dates between calendars, ...etc.). [Kahlid - 2bits]

[sinasalek] : I'm Agree with Khalid opinion, all of the calendar systems have simple text representation which means that there shouldn't be major problem with representing date in different calendar systems, and also think that calendar module should be responsible for creating date widget for forms. storing date as SQL standard calendar (Gregorian) or as timestamp in database would be good idea for preventing incompatibility with other tools and modules.
Implementing different calendar systems in my opinion has four parts :

  • Display simple
  • Display advanced (generic API for other visual tools)
  • Date Entry (Converting , validation , widgets, etc)
  • Storing in storage (database usually)

The first three parts are not easy to implement but it can be done without too much problems. i managed to implement them partially in calendar_systems module.
But the last part is complex, it requires some serious research and thinking. Since few or no Database Engines support date calculations for non Gregorian calendar systems.
lets see few examples of this complexity:

  • Explode all parts of the calendar into separate fields , to become able to do calculations.
    • The first problem with this approach is it's not possible to do certain calculations only using pure math (like datediff , because each year and month have different number of days).
    • The second problem is when content requires more then 2 date field. in this case we may end up with 30 or even more fields just for date.
    • The third one is very long SQL queries :) even for a simple filter by date query.
  • Using the advanced features like stored procedures to implement date functions for other calendar systems.
    • The first problem with this approach is performance,
    • The second is a separated code in database.
    • The third is lack of support for advanced features on some db back-ends

There is a module started by sinasalek to accommodate different calendar systems. Check the calendar systems project. This module currently supports Gregorian and Iranian calendars for Drupal 5 and 6

Code snippets that will do conversions for various calendars

Islamic (Hijri) -
Iranian (Shamsi) -

List of popular calendar systems

According to Wikipedia ( the most popular calendar systems currently are Gregorian , Iranian (Persian) , Islamic (Arabic), Chinese, Hebrew, Hindu and Julian calendar system...

Links to resources on this subject

PHP Supported RFCs with samples


Marat's picture

Hi Karen,

Thank you for opening this page. Also, many thanks to Kahlid - 2bits for supporting this project.

Regardless of all religious backgrounds of different existed calendars, the majority of dates and calendars are calculated based on some astronomical phenomenon, which include three systems:

  1. the cycle of the sun,
  2. the cycle the moon and/or
  3. the cycle the star.

Christian calendar (Gregorian) is solar calendar. Islamic calendar (Hijri) is lunisolar calendar. Samvat (Hindu) is sidereal calendar. “The Chinese calendar is a lunisolar calendar, incorporating elements of a lunar calendar with those of a solar calendar,” and so on for the rest of calenders.

This is the start point in my opinion. The calculation methods of date is what we should consider, either solar or lunar, and in advance stage, sidereal.

Drupal’s calendar calculation is based on the sun cycle regardless of its religious background. It will be a great idea to have another method of calculating date based on the moon cycle, which can be used for many other calendars. The way to convert from sun calendar system to moon calendar system is described in this page (

Once we have these calendars based on calculation (solar, lunar and sidereal), everyone can add events or whatever to any calender.

In this way, I think Drupal can cover mostly all calenders.


As long as i know, drupal

sinasalek's picture

As long as i know, drupal uses PHP's and MySQL's build-in functions for date calculations. besides this is a localization feature, which means that we should take different country's rules into account. some countries have their own version of the original calendar they're using.

Iranian (Shamsi)

alimosavi's picture

thank you allot to open this group .

I am administrator of . this site the firstly Persian community of drupal user.
I and my members need for Iranian (Shamsi) date. I have to edit file for this do.
I use jdate() function for change all system date.

It is work but I have to edit error function in the file in iclude folder for get not eror for valid date.
I know this way it in the risk but it was emergency for we .
It is better that create a modules to can do it .
I ready to share my information to all.

you cad download my project :

Persian support of drupal :

Persian support of drupal :

Jewish calendars

yhager's picture

The calculation of a jewish date from a gregorian date is well known, and can easily be integrated.

The jewish calendar is basically a lunar calendar, on a monthly basis, but solar on the yearly basis.

A few notes that need to be considered:
* The number of days in a month is not constant. The same month can have a different number of days in different years
* The number of months in a year is 12 or 13 (this is to adapt the solar calendar to the lunar one)
* The number of days in a year is different every year (not sure about this one)
* The number of days in a week is always 7, day names can be translated using the existing translation system
* The first day of the week is Sunday, the weekend is Fri-Sat.
* Month names cannot be translated since the number of months per year is not constant
* The most difficult point to understand is when the date is changing. In the jewish calendar, the date switches AT SUNSET, and not at midnight. This means that in order to know the date, one needs to know the time the sun sets.
* Timezones are treated in the same way as in gregorian calendar.
* I don't see a difficulty with date formats and aliases of days or months

yhager, do you have any

sinasalek's picture

yhager, do you have any algorithm implemented in PHP for converting gregorian to jewish and vise versa.

John Walker's Calendar Converter

farshid's picture

Hi guys

I don't know if you have already seen this:
this is a set of JavaScript functions by John Walker, converting many calendars to each other, I have converted the script to php, it is in progress, find them in the attachments, to test this just make a virtual directory pointing to files and brows index.php, it should show today date in all calendars. the buttons are not functional.
May be this could be a good script to go on... not to mention I am a little worried about the performance, may be we need something more accurate, or may be some one can improves this scripts performance, for Persian/Gregorian calendar I usually use some other scripts, but this one includes almost any calendar I think, refer to the link above.

any ideas?

Thanks, quite useful. Looks

sinasalek's picture

Thanks, quite useful. Looks good, i'll give it a try later.

how to use

boraghi's picture

thanks a lot.
please put a comment for use this module.
age emkan dare ye rahnemayi konid.
man nasb kardam va vaghti faalesh mikonam nemidunam koja va hetor azash estefade konam !
aya be soorat pishfarz ba tayin zaban site tarikh tabdil misha?

error in install this module

boraghi's picture

after copy this module and enabling it this messages occur:

Warning: Call-time pass-by-reference has been deprecated in C:\wamp2i\www\drupal-farsi2\sites\all\modules\calendar_systems\calendar_systems.module on line 136

Warning: Call-time pass-by-reference has been deprecated in C:\wamp2i\www\drupal-farsi2\sites\all\modules\calendar_systems\calendar\lib\ on line 97

Warning: Call-time pass-by-reference has been deprecated in C:\wamp2i\www\drupal-farsi2\sites\all\modules\calendar_systems\calendar\lib\ on line 99

Warning: Call-time pass-by-reference has been deprecated in C:\wamp2i\www\drupal-farsi2\sites\all\modules\calendar_systems\calendar\lib\ on line 326

please help me to run successfully this.

$gregorianMonth =

mik's picture

$gregorianMonth = date(n);
$gregorianDay = date(j);
$gregorianYear = date(Y);

$jdDate = gregoriantojd($gregorianMonth,$gregorianDay,$gregorianYear);

$hebrewMonthName = jdmonthname($jdDate,4);

$hebrewDate = jdtojewish($jdDate);

list($hebrewMonth, $hebrewDay, $hebrewYear) = split('/',$hebrewDate);

echo "$hebrewDay $hebrewMonthName $hebrewYear";

drupal core issue for this?

klonos's picture

Is there any core issue for this?

Calendar Systems module

klonos's picture

... letting people know of the Calendar Systems module that is related. I think a lot of work has been done there. It already supports setting a site-default calendar, as well as a calendar per locale!

Once you take a look at it and if you like it, please consider subscribing to this issue in its queue in order to make some noise about it and get it fixed: Porting required patch to Drupal Core

Thanx in advance everyone.

Drupal core issue

Gábor Hojtsy's picture

Swappable calendar systems are proposed for Drupal 8 core here:

fatal error in drupal 7.x

bahman2216's picture

here is my problem when I call date_fa

Fatal error: Class 'cmfcDateTime' not found in \sites\all\modules\calendar_systems\calendar\v1\calendarSystems\ on line 236

Jewish calendar support in PHP.

majortom's picture has a conversion module for the Jewish calendar:

It also has the inverse.

Hope this helps. :-)

Event Management Systems

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week