To format a date like "October 13, 2014" in PHP, you can use the date()
function along with the strtotime()
function to convert a string to a Unix timestamp:
main.php89 chars3 lines
In the date()
function, "F d, Y"
specifies the format of the output date string, where:
F
: A full textual representation of the month (e.g. January, February)d
: Day of the month, 2 digits with leading zeros (e.g. 01 to 31)Y
: A full numeric representation of a year, 4 digits (e.g. 1999, 2003)The strtotime()
function converts the string "2014-10-13"
to a Unix timestamp that can be used as the second argument of the date()
function.
gistlibby LogSnag