开发者

Zend Framework date without hours minutes and seconds

Anybo开发者_StackOverflowdy 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.


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


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


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')));?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜