如何从WP API中以WordPress中”get_the_date()”的相同格式获取发布日期

我的页面包含:1.显示最后一个帖子的部分, 并按On格式显示其日期创建:” 2020年3月10日”

.2表格单击后通过wp-api添加新帖子

然后, 从响应中, 我想用上次创建日期来更新该部分, 但是我使用了另一种格式。

json中的日期格式为’2020-03-10T11:53:10’不喜欢On格式中的格式:” 2020年3月10日”

如何获取它或将其格式化为与get_the_date()相同的格式;


#1


使用PHP日期格式功能

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

检查此参考以获取其他格式选项

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

来源:

https://www.srcmini02.com/63340.html

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_37645.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?