You can use the strftime() function to format a date in PHP. Here's an example code snippet that formats a date to the format "October 13, 2014 11:13 am":
main.php121 chars4 lines
In this example, we first convert the input string '2014-10-13 11:13:00' to a Unix timestamp using the strtotime() function. Then we pass this timestamp to the strftime() function along with the desired format string '%B %d, %Y %I:%M %p'.
The %B code represents the full month name (e.g. "October"), %d represents the day of the month with leading zeros (e.g. "13"), %Y represents the four-digit year (e.g. "2014"), %I represents the 12-hour format hour with leading zeros (e.g. "11"), %M represents the minute with leading zeros (e.g. "13"), and %p represents "am" or "pm" in lowercase format.
The resulting output will be "October 13, 2014 11:13 am".
gistlibby LogSnag