0

Zend Localeを使用して、たとえば17:00から5:00pmに時間を変換する方法はありますか?

ドキュメントのメソッドをそのまま(タイプミスがあります)試しましたが、機能しません。「dd.MM.yyyy」(M <> y)を使用して「日付「13:44:42」を解析できません」というエラーが発生します。

$locale = new Zend_Locale('de_AT');
if (Zend_Locale_Format::getTime('13:44:42',
                            array('date_format' =>
                                      Zend_Locale_Format::STANDARD,
                                  'locale' => $locale))) {
    print "time";
} else {
    print "not a time";
}

次に、2ステップの方法を試しました。最初に現在のロケールの時刻形式を取得し、それをgetTime関数で使用します。

$locale = new Zend_Locale('en_US');
$tf = Zend_Locale_Format::getTimeFormat($locale);
$test = Zend_Locale_Format::getTime('17:00', array('date_format' => $tf, 'locale' => $locale));

これは結果を返しますが、私が持っていたものを返すだけです

array('date_format'=>'h:mm:ss a', 'locale'=>'en_US', 'hour'=>'17', 'minute'=>'00')

解析しようとしている実際のロケールに時間を変換するものはありますか?

4

1 に答える 1

0

Zend_Date希望する形式で日付を取得するには、ロケールで使用する必要があります。

$date    = new Zend_Date(); // Default ISO format type & en_US
// Set the time and pass the format I am using to set the time
$date->setTime('17:00:00', 'HH:mm:ss'); 
echo $date; // Jul 15, 2011 5:00:00 PM

編集

での使用方法のZend_Locale詳細Zend_Date

$locale = new Zend_Locale('de_AT');
echo  $date->toString(Zend_Locale_Format::getTimeFormat($locale)) ; // 17:00:00
$locale = new Zend_Locale('en_US');
echo  $date->toString(Zend_Locale_Format::getTimeFormat($locale)) ; // 5:00:00 PM
于 2011-07-15T16:01:11.537 に答える