How to format a getUpdatedAt() kind of date in Symfony?
Posted
by Guillaume Flandre
on Stack Overflow
See other posts from Stack Overflow
or by Guillaume Flandre
Published on 2010-01-26T17:29:18Z
Indexed on
2010/06/15
8:42 UTC
Read the original article
Hit count: 228
I'd like to change the formatting of a date in Symfony 1.4
The default one being:
<?php echo $question->getUpdatedAt();
// Returns 2010-01-26 16:23:53
?>
I'd like my date to be formatted like so: 26/01/2010 - 16h23
I tried using the format_date
helper DateHelper
class.
Unfortunately the API is rather empty (something really needs to be done about it.)
Browsing the helper's source code, I found that a second argument, format, can be passed.
I assumed it was using the same syntax as PHP's date function. But here's what it outputs (same example as above):
<?php sfContext::getInstance()->getConfiguration()->loadHelpers('Date');
// [...]
echo format_date($question->getUpdatedAt(),'d/m/y - H\hi')
// Returns 26/23/2010 - 16\4i
I'm sure I'm not the first one having trouble doing this but I've been Googling around and nothing accurate showed up.
Do you guys have any idea how to format a date in Symfony 1.4?
© Stack Overflow or respective owner