Yii 1.1: hijrishamsidatetime

Hijri Shamsi (Solar Hijri) date time extension
4 followers

HijriShamsiDateTime extension is a convenient and complete solution for users who want to use Hijri Shamsi date in their projects.

The modern Iranian calendar (Solar Hijri calendar (SH)) is now the official calendar in Iran and Afghanistan. It begins on the vernal equinox as determined by astronomical calculations for the Iran Standard Time meridian (52.5°E or GMT+3.5h). This determination of starting moment is more accurate than the Gregorian calendar as far as predicting the date of the vernal equinox is concerned because it uses astronomical calculation rather than mathematical rules.

Requirements

Yii 1.1 or above, PHP 5

Install

  1. Extract to extensions directory
  2. copy the messages folder to you protected folder
  3. Add as component to main config
// To sopport I18N translation ->> folder messages/fa
    'language' => 'fa', // for now fa, en languages are provided
 
    // application components
    'components' => array(
                /*---- other components*/
        // Hijri Shamsi date
        'shamsidate' => array(
            'class' => 'ext.shamsidate.HijriShamsiDateTime',
        ),

Usage

see Date Function in PHP for the full date format

Yii::app()->shamsidate->date("H:i A l, d F Y",time()) // formatting is like date function
//will return 20:15 بعد از ظهر دو شنبه, 21 تیر 1391

To get an array of month, day, year in Hijri Shamsi

Yii::app()->shamsidate->GregorianToHijriShamsi(20, 02,  1976);
// will return Hijri Shamsi date[int month, int day, int year]

To parse about any English textual datetime description into a Hijri Shamsi format if no format the date returned will be Hijri Shamsi d-m-Y

Yii::app()->shamsidate->strToHijriShamsi("19 June 2012")
// will return a Date in Hijri Shamsi d-m-Y if not formatted
//-------- Or -----------
Yii::app()->shamsidate->strToHijriShamsi("11 July 2012", "l, d F Y")
// will return a Date in Hijri Shamsi as formatted like دو شنبه, 21 تیر 1391

Total 1 comment

#13689 report it
srm at 2013/06/17 09:53am
Problem

I extracted this file in extenuation folder. cut the message folder and paste in protected.and then out the shamsidate folder in extension folder and remove other folder (_MACOSX and hijri-shamsi). put the code in the main.php of config folder. My question is, where i have to put "Yii::app()->shamsidate->date("H:i A l, d F Y",time())". I use demo blog of yii.i guess i have to put this command on view of my post. thanks for considration

Leave a comment

Please to leave your comment.

Create extension