I'm currently using YouTube's feed API to get information about a YouTube channel's uploaded videos. An example feed would be something like http://gdata.youtube.com/feeds/api/users/google/uploads?v=2
Timestamps in the feed are in the format 2011-04-27T20:54:42.000Z
. How would I convert that to something more readable, like April开发者_运维知识库 27th, 2011 at 8:54:42pm
?
Use DateTime::createFromFormat
to create a new DateTime object from that format, then you can output it however you want using the object's format
method.
You can use a combination of strtotime, which converts a string into a UNIX timestamp, and date, which converts a timestamp into human-readable output:
echo date( 'F dS, Y \a\t h:i:sa', strtotime("2011-04-27T20:54:42.000Z") );
Live example
精彩评论