【问题标题】:Zend Jalali DateZend Jalali 日期
【发布时间】:2011-07-07 11:54:31
【问题描述】:

Zend 是否支持 jalali 日期和日历?
我怎么能得到那个?
我试过这个:

    $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
            )
        ); 

不会像我想要的那样工作。

【问题讨论】:

    标签: php zend-framework magento zend-date persian


    【解决方案1】:

    Zend_Date 支持 fa_IR 日期,但我不相信它会进行从公历到 Jalali 的日历转换。您必须手动设置日期。然而,这里是你如何使用Zend_LocaleZend_Date 来表示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 قبل از ظهر
    

    编辑

    我忘了提。我将 Zend_Date format_type 设置为 php 作为默认格式

    Zend_Date::setOptions(array('format_type' => 'php'));
    

    【讨论】:

    • Tir 的 16 日(Jalali 日历的第 4 个月)是 7 月 6 日NOT 4 月 16 日(公历的第 4 个月)。您不能为第一个参数输入 Jalali 日期。
    • آوریل 16, 1390 表示 1390 年 4 月 16 日。
    猜你喜欢
    • 1970-01-01
    • 2015-01-24
    • 1970-01-01
    • 1970-01-01
    • 2022-07-31
    • 2017-09-27
    • 2020-09-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多