Mayeenul Islam
Mayeenul Islam

Reputation: 4772

Post Modified date in a formated way in WordPress

Getting the post_modified date is: 2013-07-11 01:45:40.

I DON'T NEED the time (01:45:40) here.

I need the date portion to be displayed as: July 11, 2013.

I'm aware about PHP Date & Time function, and also aware about WordPress date and time functions.

But I'm afraid I can't understand how to get it easily.

Upvotes: 0

Views: 291

Answers (1)

Amal
Amal

Reputation: 76646

You can use PHP's strtotime() along with date(). It converts the given date into a timestamp and then back.

Code:

<?php

$date = "2013-07-11 01:45:40";
$timestamp = strtotime($date);

echo date('F d, Y', $timestamp); //output: July 11, 2013

?>

Upvotes: 1

Related Questions