本文整理汇总了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);
}
示例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);
}
示例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) {
示例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');
}
示例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');
}
示例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);
}