You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在WordPress中修改已发布文章的PHP日期格式

Fixing WordPress Published Post Date Format

Hey there! Changing the date format in your WordPress theme is straightforward once you know the right PHP date format strings.

Right now you're using <?php the_time('m.d.y'); ?> which outputs something like 1.20.2018. To get the full month name, followed by the day (without leading zeros) and four-digit year like January 20, 2018, you just need to swap out the format string in the the_time() function.

Here's the updated code you should use:

<?php the_time('F j, Y'); ?></div>

Let me break down what each part of the new format string does:

  • F: Outputs the full textual name of the month (e.g., January, February)
  • j: Displays the day of the month without leading zeros (e.g., 1, 20, 31)
  • Y: Shows the four-digit year (e.g., 2018, 2024)

If you ever need to tweak the format further, remember that the_time() uses the same format codes as PHP's native date() function—so you can mix and match codes to get exactly the date style you want.

内容的提问来源于stack exchange,提问作者Hemant Nagori

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 08:38:38