Zend Framework date without hours minutes and seconds

不羁岁月 提交于 2019-12-23 05:42:16

问题


Anybody can help me to get date formated with Zend framework

What I do is:

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

Result I get is: May 22, 2010 12:00:00 AM

I what I need is: May 22, 2010

Thanks.


回答1:


You can use the 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);



回答2:


Only with 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);



回答3:


The date is returned as ISO standard date, unless you specify a format, as mentioned on the Zend Framework documentation on Zend_Data

A much easier solution would be:

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


来源:https://stackoverflow.com/questions/2884469/zend-framework-date-without-hours-minutes-and-seconds

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!