Yii 1.1: jdatetime

Jalali Date Time Extention

JDateTime extension is a convenient and complete solution for users who want to use jalali date in their projects.


Yii 1.1 or above


  • Extract to extensions directory
  • Add as component to main config
'jdate' => array(
    'class' => 'ext.jdate.JDateTime',
    'convert' => true,
    'jalali' => true,
    'timezone' => 'Asia/Tehran',


Yii::app()->jdate->date("H:i:s Y/m/d",time())

Total 14 comments

#17918 report it
kazemi_morteza at 2014/08/11 09:17am
so good

Thanks.MR Ramini

#14119 report it
javad at 2013/07/21 01:23am

big like ;)

#12813 report it
Shahcheraghean at 2013/04/13 06:14am
just show now

Dear Mr. Ramin Farmani. Thank's for your extension and your idea about putting it on the git. what about my first part of the question?

#12811 report it
Ramin Farmani at 2013/04/13 03:54am
just show now

Hi Shahcheraghean there is no any git repo yet because there is no any update for it until next issue report! thanks for using this extnsion and if I find any free time in the future I will release a bunch of component on github under GPL license so you guys can use them freely may be this happend after next major Yii framework.

#12810 report it
Shahcheraghean at 2013/04/13 03:35am
just show now

Hi. I save the time in my database in DateTime format. when i use:

echo Yii::app()->jdate->date('Y-m-d H:i:s',strtotime($model->creatino_time));

it just show no time in jalali, but in this case:

echo date('Y-m-d H:i:s',$model->creatino_time);

it do the right. By the way, Is there any git repository to fork on it?

#12255 report it
Nabi at 2013/03/09 09:17pm
a bug and a suggestion

Hi dear Ramin,

Thanks for great extension.

Would do I know what's "امرداد" ?!!! (on line 455) :-D

And also, I suggest to change some functions from private to public about functions like getDayNames(), getMonthNames(), and maybe more functions, and maybe convertNumbers(). because for example getMonthNames() many used in generate dropDownList to show all months, and maybe others be like this functions having benefit for public used.


#8543 report it
Ramin Farmani at 2012/06/11 10:13am

as I said before this extension simulate date function for jalali date so there is no any reverse method to convert jalali to Gregorian. your effort to support jalali date in model validations is totally welcomed ;) thanks a lot...

#8541 report it
mohamadaliakbari at 2012/06/11 08:48am
some features


is there any reverse method to convert Jalali to Gregorian? I'm currently work on integrating jalalidatepicker with this module and provide integration with yii AR models.

so I should provide afterFind and beforeSave and validation rules methods.

now let me know if your extension let me convert Jalali to Gregorian to save all dates in standard mySql DATE type in beforeSave method...

#8539 report it
Ramin Farmani at 2012/06/11 08:12am
refer to mohamadaliakbari

hi mohamad. please feel free to ask any kind of question do you have about this extension there is no any document available for this simple extension although I don't think you need more explanation to use. it's quite straightforward. function "Yii::app()->jdate->date()" do similar php date function and you can use it just as date() function but the role of this extension is not about i18n or bla bla bla. if you need and Jalali date validation in your model please read yii core validator class and make it and if it's possible for you share it with other! this is the only way to say thank you to me or any one who share their works/time/experience for you :)

#8538 report it
mohamadaliakbari at 2012/06/11 07:58am
any documentation?

is function Yii::app()->jdate->date("H:i:s Y/m/d",time()); accept only time() (timestamps)? is there any integration rule for models?

#7566 report it
Ramin Farmani at 2012/03/30 10:12am
Fatal error: Call to undefined method JDateTime::init()

new version has been just released fatal error fixed in new version

#7562 report it
javad at 2012/03/30 07:38am


I have a problem with version 0.1

Fatal error: Call to undefined method JDateTime::init() in ...\framework\base\CModule.php on line 388

#7555 report it
Ramin Farmani at 2012/03/29 04:50pm
font was not wrong

sorry users! there was an error in file encoding and in the new version file encoding problems solved please update your extention

#7553 report it
Nabi at 2012/03/29 03:17pm
Farsi font is wrong.


Near 369 line:
$farsi_array = array("?", "?", "?", "?", "?", "?", "?", "?", "?", "?");
Farsi font is wrong.
This must to be corrected.


Leave a comment

Please to leave your comment.

Create extension