Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get day month and year of any post from WP post object?Wordpress

Tags:

php

wordpress

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
like image 836
Kamlesh Avatar asked Mar 22 '23 03:03

Kamlesh


2 Answers

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.

like image 70
Code Lღver Avatar answered Apr 05 '23 23:04

Code Lღver


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.

like image 24
user2798091 Avatar answered Apr 06 '23 00:04

user2798091