简体   繁体   中英

How to get post published date from the wp api in the same format of "get_the_date( )" in wordpress

I have page that contain: 1. Section that show the last post and show his date creation by On format : "March 10, 2020"

.2 Form That on click add post new post by the wp-api

Then from the response, I like to update the section with the last date creation but I got in a different format.

The date from the json is in the format '2020-03-10T11:53:10' Not like The format from the On format : "March 10, 2020"

How to get it or format it the same one as get_the_date();

Use the PHP date format function

$date = new Date("F d, Y", strtotime($yourDateString));

Check this reference for other format options

https://www.php.net/manual/en/function.date.php

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM