Zend Framework日期没有小时分钟和秒

时间:2010-05-21 18:11:21

标签: zend-framework

任何人都可以帮助我使用Zend框架格式化日期

我的工作是:

<?php echo new Zend_Date(2010-05-23, false, 'en');?>

我得到的结果:2010年5月22日上午12:00:00

我需要的是: 2010年5月22日

感谢。

3 个答案:

答案 0 :(得分:3)

您可以使用string formatting options and constants

// Using the strings for reading the format:
$date = new Zend_Date('2010-05-23', 'yyyy-MM-dd');
// Using the constants for format:
echo $date->toString(Zend_Date::MONTH_NAME." ".Zend_Date::DAY_SHORT.", ".Zend_Date::YEAR);

答案 1 :(得分:0)

除非您指定格式,否则日期将作为ISO标准日期返回,如Zend_Data上的Zend Framework文档中所述

更简单的解决方案是:

 <?php echo date("F d, Y", strtotime(new Zend_Date(2010-05-23, false, 'en')));?>

答案 2 :(得分:0)

仅限Zend_Date ...

$dateArray = array('year' => 2010, 'month' => 5, 'day' => 23);
$now = new Zend_Date($dateArray);
$date = $now->toString(Zend_Date::MONTH_NAME . ' ' . Zend_Date::DAY . ', ' . Zend_Date::YEAR);
相关问题