[英]How to get post published date from the wp api in the same format of "get_the_date( )" in wordpress
我有包含以下內容的頁面: 1. 顯示最后一個帖子的部分,並按格式顯示他的日期創建: “2020 年 3 月 10 日”
.2 通過 wp-api 單擊添加發布新帖子的表單
然后從響應中,我喜歡用最后一個日期創建更新該部分,但我得到了不同的格式。
json 中的日期格式為“2020-03-10T11:53:10”與 On 格式中的格式不同: “2020 年 3 月 10 日”
如何獲取或格式化與get_the_date();
相同的格式get_the_date();
使用PHP日期格式功能
$date = new Date("F d, Y", strtotime($yourDateString));
檢查此參考以了解其他格式選項
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.