wordpress get post time
Use the following code to get the post time in WordPress:
$post_date = get_the_time('Y-m-d H:i:s');
- Retrieve the time of the current post using the
get_the_time
function. - Format the time according to the 'Y-m-d H:i:s' format, which represents year-month-day hour:minute:second.
- Store the formatted time in the variable
$post_date
.