如何在WordPress中修改已发布文章的PHP日期格式
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

