Reputation: 123
I have WordPress theme and I am using get_the_date
function to get the publish date of post :
<?php echo get_the_date( 'M-d-y' ); ?>
But it seems it will be better to use get_option( 'date_format' ).
How can I display post publish date using get_option
function?
Upvotes: 0
Views: 520
Reputation: 2552
Doesn't need to use get_option
for getting post published date. You can get that by using get_the_date
function properly.
Here is the solution:
Make the date appear as Monday January 11, 2017, use
$post_date = get_the_date( 'l F j, Y' ); echo $post_date;
To make the date appear as Wed Jan 9, use
$post_date = get_the_date( 'D M j' ); echo $post_date;
Read more about get_the_date and check date formatting options here, in wordpress docs.
Upvotes: 1