Site logo

Archived topic

How to shorten month name?

3 replies · Started by Matic on December 18, 2020

Viewing posts 1–4 of 4

Hi,

I am using shortcode [modified_date] that calls the following PHP function:

function post_modified_date() {
    return get_the_modified_date();
}
add_shortcode( 'modified_date', 'post_modified_date' );

This returns a date in the following format: December 18, 2020. How can I make it so that every month would be shortened to 3 letter only followed by a dot, so it would read: Dec. 18, 2020?

Cheers,
Matic

Thank you for the link! I don't know how I missed it.

Your code didn't work because it needed some additional tweaking.

For anyone else with the same problem, the code that worked for me:

function post_modified_date() {
    return get_the_modified_date('M. j, Y');
}
add_shortcode( 'modified_date', 'post_modified_date' );

Thank you for your help!
Cheers,
Matic

Glad to hear that.

This archived topic is closed to new replies.