I use a plugin that shows me list of posts and I want to change format of date.
This is show me date like this:
24 january 2015 12:20:11
and this is the code of above output:
<?php echo $post->getCreatedTime(); ?>
But I want to show date like this:
24 january 2015
I use this code but this is show time in wrong month and date, for example instead of 24 january 2015 it shows me: Oct 12, 2015 !!!
<?php $_ct= new Zend_Date($post->getCreatedTime()); echo $_ct->toString('MMM dd, yyyy'); ?>
I don't have any idea why this is happen!!!
How can I fix it?
Best Answer
Don't forget about locale! As all other examples can cause issues for people from different time zones.
inside
date()
you can put any date and call method->toString()
with some param.Pattern examples you can find in
Varien_Date
or use any you like.
For example for current time full call will look like this: