Parse date from the past.
So lets say I have a bunch of dates in the format of m/d/y
. So say our date is 1/1/2001, I want it to display January 1st, 200开发者_如何学C1
.
How would I do that?
I'm a big fan of strtotime()
$original = '1/1/2001';
echo date("F jS, Y", strtotime($original));
Also don't forget about php's DateTime object, which I've finally been using lately.
$original = '1/1/2001';
$Date = new DateTime($original);
echo $Date->format("F jS, Y");
date
accepts an optional timestamp as second argument:
echo date("F jS, Y", mktime(0, 0, 0, 1, 1, 2001));
// prints: January 1st, 2001
To supply mktime
with the right arguments, take a look at strptime
.
精彩评论