You can use the DateTime
class along with the format()
method to achieve this format. Here's an example code block:
main.php124 chars4 lines
This code will output October 13, 2014 11:13:00.000 AM
.
Explanation:
DateTime
object using the input date string.format()
method on the object with the desired format string as the argument.F
represents the full textual month name, d
represents the day of the month, Y
represents the year, h
represents the hour (12-hour format), i
represents the minutes, s
represents the seconds, u
represents the microseconds, and A
represents the AM/PM indicator in uppercase.gistlibby LogSnag