How to get Last Post Publish Date using the
get_lastpostdate function in WordPress?
get_lastpostdate function is helpful when you want to retrieve the latest post publish date.
This function’s syntax is easy to understand:
$timezone parameter to get the date based on your selected timezone.
$postType can determine what type of posts you want information about.
How to get the Date that a Post was Modified using the
get_lastpostmodified function in WordPress?
get_lastpostmodified function will return a date string that represents the last date and time a post was modified on the current website.
The syntax is much like the previous function:
Parameters are the same as
Example of running these two functions in my case:
$lastPostPublishDate = get_lastpostdate(); //value: 2021-11-03 07:32:44.000000 $lastPostModifyDate = get_lastpostmodified(); //value: 2021-11-05 11:30:53.000000
Returned value was correct for me in the local work space.
If you are interested in more information about post dates, you can follow these articles on my blog: