Formatting Date and Time
When a person wants to publish a date or time on a web page with PHP, they generally want to publish something quick and simple.
Unfortunately, there are a myriad of ways to publish dates and times. Here is a sampling, all representing the moment this page was loaded (using GMT time zone).
Further below is a generator designed to help you create the PHP code to publish a perfectly formatted date or time on your web page.
The generator presents the dozens of cryptic formatting characters as easy-to-understand descriptions. Tap the "3‑letter day of the week name" description, for example, and the generator correctly inserts the character "D" into the format you will use.
(All date and time formatting characters and what they're used for are listed on the PHP date() Manual page.)
The date/time code format generator has an input field where formatting, space, and punctuation characters are specified.
The formatting characters are inserted by tapping the short descriptions for formatting options you choose. (The descriptions are below the input field.) Then, insert spaces or punctuation characters as appropriate.
You'll end up with the correct format to publish the date and/or time. (The code and previews are provided in the generator.)
Specify formatting (tap links below), spaces, and punctuation.
Formatting Links:
Day ▼
Week ▼
Month ▼
Year ▼
Time ▼
Timezone ▼
Full Date and Time ▼
Use the generator to test various date and time formats until the preview shows you exactly what you're looking for.
It provides copy and paste code for publishing that date/time on your web page.
(This article first appeared with an issue of the Possibilities newsletter.)
Will Bontrager