當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Zend_Date::setIso方法代碼示例

本文整理匯總了PHP中Zend_Date::setIso方法的典型用法代碼示例。如果您正苦於以下問題:PHP Zend_Date::setIso方法的具體用法?PHP Zend_Date::setIso怎麽用?PHP Zend_Date::setIso使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Zend_Date的用法示例。


在下文中一共展示了Zend_Date::setIso方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: formatDate

 /**
  * Prepare date for save in DB
  *
  * string format used from input fields (all date input fields need apply locale settings)
  * int value can be declared in code (this meen whot we use valid date)
  *
  * @param   string | int $date
  * @return  string
  */
 public function formatDate($date)
 {
     if (empty($date)) {
         return null;
     }
     // unix timestamp given - simply instantiate date object
     if (preg_match('/^[0-9]+$/', $date)) {
         $date = new Zend_Date((int) $date);
     } else {
         if (preg_match('#^\\d{4}-\\d{2}-\\d{2}( \\d{2}:\\d{2}:\\d{2})?$#', $date)) {
             $zendDate = new Zend_Date();
             $date = $zendDate->setIso($date);
         } else {
             $date = Mage::app()->getLocale()->date($date, Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT), null, false);
         }
     }
     return $date->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
 }
開發者ID:votanlean,項目名稱:Magento-Pruebas,代碼行數:27,代碼來源:Datetime.php

示例2: _formatDateForSave

 /**
  * Prepare date for save in DB
  *
  * string format used from input fields (all date input fields need apply locale settings)
  * int value can be declared in code (this meen whot we use valid date)
  *
  * @param   string | int $date
  * @return  string
  */
 protected function _formatDateForSave($date, $format)
 {
     if (empty($date)) {
         return null;
     }
     if ($format) {
         $date = Mage::app()->getLocale()->date($date, $format, null, false);
     } elseif (preg_match('/^[0-9]+$/', $date)) {
         // unix timestamp given - simply instantiate date object
         $date = new Zend_Date((int) $date);
     } else {
         if (preg_match('#^\\d{4}-\\d{2}-\\d{2}( \\d{2}:\\d{2}:\\d{2})?$#', $date)) {
             // international format
             $zendDate = new Zend_Date();
             $date = $zendDate->setIso($date);
         } else {
             // parse this date in current locale, do not apply GMT offset
             $date = Mage::app()->getLocale()->date($date, Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT), null, false);
         }
     }
     return $date->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
 }
開發者ID:cesarfelip3,項目名稱:clevermage_new,代碼行數:31,代碼來源:Date.php

示例3: testLoose


//.........這裏部分代碼省略.........
         // success
     }
     try {
         $date->compareTime(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setDate(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addDate(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subDate(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareDate(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setIso(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addIso(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subIso(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareIso(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setArpa(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addArpa(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
開發者ID:jsnshrmn,項目名稱:Suma,代碼行數:67,代碼來源:DateTest.php

示例4: testAddIso

 /**
  * Test for addIso
  */
 public function testAddIso()
 {
     $locale = new Zend_Locale('de_AT');
     $date = new Zend_Date(1234567890, $locale);
     $d2 = new Zend_Date(1234567899, $locale);
     $result = $date->addIso(Zend_Date::now());
     $this->assertTrue($result instanceof Zend_Date);
     $date = new Zend_Date(0, $locale);
     $result = $date->setIso('2002-01-04T01:00:00+0100');
     $result = $date->addIso('0000-00-00T01:00:00+0100');
     $this->assertSame($result->get(Zend_Date::W3C), '2002-01-04T01:00:00+01:00');
     $this->assertSame($date->get(Zend_Date::W3C), '2002-01-04T01:00:00+01:00');
     $date->addIso('0001-01-01T01:01:01+0100');
     $this->assertSame($date->get(Zend_Date::W3C), '2003-02-05T01:01:01+01:00');
     $date = new Zend_Date(1234567890, $locale);
     $date->addIso($d2);
     $this->assertSame($date->get(Zend_Date::W3C), '4018-04-28T00:03:09+01:00');
 }
開發者ID:jorgenils,項目名稱:zend-framework,代碼行數:21,代碼來源:DateTest.php

示例5: _convertTimezone

 protected function _convertTimezone($date, $from, $to)
 {
     $dateObject = new Zend_Date();
     $dateObject->setTimezone($from);
     $dateObject->setIso($date);
     $dateObject->setTimezone($to);
     return $dateObject->toString('yyyy-MM-dd HH:mm:ss');
 }
開發者ID:febryantosulistyo,項目名稱:ClassicSocial,代碼行數:8,代碼來源:AdminAdsController.php

示例6: formatDate

 public function formatDate($_f0c57a04a51d1d900c8d28a111ab8f340a17465b)
 {
     if (empty($_f0c57a04a51d1d900c8d28a111ab8f340a17465b)) {
         return 0;
     }
     if (preg_match('/^[0-9]+$/', $_f0c57a04a51d1d900c8d28a111ab8f340a17465b)) {
         if ($_f0c57a04a51d1d900c8d28a111ab8f340a17465b <= 0) {
             return 0;
         }
         $_f0c57a04a51d1d900c8d28a111ab8f340a17465b = new Zend_Date((int) $_f0c57a04a51d1d900c8d28a111ab8f340a17465b);
     } else {
         if (preg_match('#^\\d{4}-\\d{2}-\\d{2}( \\d{2}:\\d{2}:\\d{2})?$#', $_f0c57a04a51d1d900c8d28a111ab8f340a17465b)) {
             if ($_f0c57a04a51d1d900c8d28a111ab8f340a17465b <= 0) {
                 return 0;
             }
             $_bbb3c91a8584760004706197a44eb6790aba37a9 = new Zend_Date();
             $_f0c57a04a51d1d900c8d28a111ab8f340a17465b = $_bbb3c91a8584760004706197a44eb6790aba37a9->setIso($_f0c57a04a51d1d900c8d28a111ab8f340a17465b);
         } else {
             $_f0c57a04a51d1d900c8d28a111ab8f340a17465b = Mage::app()->getLocale()->date($_f0c57a04a51d1d900c8d28a111ab8f340a17465b, Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT), null, false);
         }
     }
     return $_f0c57a04a51d1d900c8d28a111ab8f340a17465b->toString(Varien_Date::DATE_INTERNAL_FORMAT);
 }
開發者ID:jronatay,項目名稱:ultimo-magento-jron,代碼行數:23,代碼來源:FrontendController.php


注:本文中的Zend_Date::setIso方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。