You can use the ->toString() method to output custom date formats like this:
$date = new Zend_Date(); // Passing no params sets to current date.
$date->toString('yyyy-MM-dd HH:mm:ss');
See http://framework.zend.com/manual/en/zend.date.constants.html#zend.date.constants.selfdefinedformats for date part specifiers.
hardik82 wrote:
Hello, can anyone tell me how i can get current date in format[yyyy-MM-dd
HH:mm:ss]
milesap wrote:
Hello,
I'm fairly new to Zend Framework, so forgive me if this is a really easy
question. I have been looking everywhere for a solution. I am trying to
get the difference between the current date and a persons birthday to see
how old they are.
$date = new Zend_Date();
$date->sub('April 3, 1980');
print $date->toString('Y');
The following prints 28, however the correct age would be 29, as the
persons birthday was a few days ago. Does it not take the month and day
into account when it subs the date? Or a better question would be what am
I doing wrong?
I have set my default timezone correctly.