Date and Time Formatting
The generator below creates program code to custom format date and time. It generates JavaScript, PHP, and Perl software code to print the date/time in your specified format.
The generated source code is a complete program in each of the 3 languages. The software source code may be modified. The article introducing the generator is here.
Usage notes are below the generator.
Formatted Date/Time Display Generator
Specifying the date/time format is done in 2 steps.
-
The format for the date/time display using placeholders for month, day, hour, and so forth.
-
The format for the placeholders themselves.
Then, copy the generated code for the programming language of your choice and paste it into your source code.
The generated program source code assumes the current date. Modify as desired.
For the Formatted Date/Time Display Generator's examples, the date/time
Step 1 —
To specify the display format, use placeholders. [placeholders]
Display format:
Step 2 —
Format the placeholders: [notes]
{W} | {Y} | {M} | {D} |
{h} | {m} | {s} | {ap} |
Format displays as:
[specify preferences]
Now —
Click the link for the programming language of your choice and copy the generated source code.
The generated code is a complete application to print the current date/time with your specified format. Modify as desired.
Usage Notes for Generated Date/Time Program Code
The generated source code is a complete application, ready to copy.
-
JavaScript — Paste it into the source code of a web page. The published date and time are according to the clock on your computer. For your site visitor's, the date/time will be according to their computer.
-
PHP — Paste it into the source code of an existing .php web page or save it as a separate .php web page. The published date and time are according to the clock on your server.
-
Perl — Save it as a .cgi or .pl file. Upload it to your server as plain text and give it 755 permissions. Type its URL into your browser or call it with an SSI tag from a .shtml web page. The published date and time are according to the clock on your server.
The generated code may be modified as needed.
Will Bontrager