Zend Framework Source Code Snippets

Displaying a localized date

Bookmark and Share
1
2
3
4
56
7
8
9
1011
12
13
14
1516
<?php
/**
 * @copyright  2009, Giorgio Sironi
 * @license    http://www.gnu.org/licenses/gpl-2.0.html GNU Public License
 * @version    $Id$ * @link       http://sf.net/projects/ossigeno
*/
 
class Otk_View_Helper_Date extends Zend_View_Helper_Abstract
{    public function date($dbDate)
    {
        $date = new Zend_Date($dbDate, Zend_Date::ISO_8601);
        return (string) $date;
    }}

Comments

You must login before commenting on a snippet. If you do not have an account, please register.

Snippet description

In input a date from database format, like '2009-03-05 18:41:00', returns a localized date based on the current locale (for Italian: gio 5 mar 2009, 18:41:00).

Snippet details

Created:
Giorgio Sironi Giorgio Sironi
1 year ago
Edited:
Giorgio Sironi Giorgio Sironi
1 year ago
Revision Id:
11
Edit Message:
Initial Release
Tags:
view helper date
Comments:
0
Views:
151
Points:
-1 (1 votes)

History

r11

Initial Release

Giorgio Sironi Giorgio Sironi
1 year ago