I am trying to get day month and year of a post from WP post object.
what I did is:
<?php
$cpost=get_post($_GET['p_id']);
echo $cpost->post_date;echo "<br>";
?>
Outputs:
2013-12-26 13:25:18
what I need is, day month and year as:
26 Dec 2013
Use this:
echo date("d M Y", strtotime($cpost->post_date));
Here is the full parameter of the date function in PHP: date function Parameters.
You can use something of the sort:
<?php the_time('j F Y'); ?>
that will show the day, month and year of when the current post was posted.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With