name name2
name name2

Reputation: 123

Using system date format

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

Answers (1)

Atlas_Gondal
Atlas_Gondal

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:

  1. Make the date appear as Monday January 11, 2017, use

    $post_date = get_the_date( 'l F j, Y' ); echo $post_date;
    
  2. 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

Related Questions