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
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
You must be logged in to post a comment.
Use this:
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.Try this:
Always use strtotime function to get Date, Month, and Year etc.
Use the options you want in date function && pass values in strtotime function.
–
Thanks
The format for the date is taken from the WordPress Settings (Settings > General).
Ref: http://codex.wordpress.org/Formatting_Date_and_Time