Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Zend Jalali Date

Does Zend support jalali date and calendar?
And How can i get that ?
I tried this:

    $locale = new Zend_Locale('fa_IR');
    $date = new Zend_Date();
    $new_date=  Zend_Locale_Format::getDate($date,
        array(
            'date_format' =>Zend_Locale_Format::getDateFormat('fa_IR'),
            'locale' => $locale,
            'fix_date' =>true
            )
        ); 

will not work as I want for me.

like image 809
R‌‌‌.. Avatar asked Nov 20 '25 14:11

R‌‌‌..


1 Answers

Zend_Date supports fa_IR dates, but I don't believe it will do calendar conversions from Gregorian to Jalali. You will have to set date manually. However, here is how you use Zend_Locale with Zend_Date for fa_IR

// Manual conversion from Gregorian date 7/7/2011 to Jalali date 1390/4/16
$date   = new Zend_Date('1390/4/16');  
$date->setLocale('fa_IR');
echo $date->toString('F j, Y, g:i a');
// prints آوریل 16, 1390, 12:00 قبل از ظهر

Edit

I forgot to mention. I have Zend_Date format_type set to php as default format

Zend_Date::setOptions(array('format_type' => 'php'));
like image 121
brady.vitrano Avatar answered Nov 23 '25 04:11

brady.vitrano



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!