0% found this document useful (0 votes)
41 views

Some PHP Tips

The document provides examples of date formatting codes that can be used with the PHP date() function. It shows different formats for days, months, years, and times. The last part lists what each date formatting code represents, such as "m" for the 2 digit month number or "D" for the 3 letter day abbreviation. The document concludes that there are many different formatting options available to output dates in the desired format.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views

Some PHP Tips

The document provides examples of date formatting codes that can be used with the PHP date() function. It shows different formats for days, months, years, and times. The last part lists what each date formatting code represents, such as "m" for the 2 digit month number or "D" for the 3 letter day abbreviation. The document concludes that there are many different formatting options available to output dates in the desired format.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Date Function Formatting

<?php $b = time (); print date("m/d/y",$b) . "<br>"; print date("D, F jS",$b) . "<br>"; print date("l, F jS Y",$b) . "<br>"; print date("g:i A",$b) . "<br>"; print date("r",$b) . "<br>"; print date("g:i:s A D, F jS Y",$b) . "<br>"; ?> As you can see in our last example there are tons of different formats that can be used in the date feature. Below is a summary of the variable used in date, and what each does. Remember they ARE CaSe sEnsItIVe: DAYS d - day of the month 2 digits (01-31) j - day of the month (1-31) D - 3 letter day (Mon - Sun) l - full name of day (Monday - Sunday) N - 1=Monday, 2=Tuesday, etc (1-7) S - suffix for date (st, nd, rd) w - 0=Sunday, 1=Monday (0-6) z - day of the year (1=365) WEEK W - week of the year (1-52) MONTH F - Full name of month (January - December) m - 2 digit month number (01-12) n - month number (1-12) M - 3 letter month (Jan - Dec) t - Days in the month (28-31) YEAR L - leap year (0 no, 1 yes) o - ISO-8601 year number (Ex. 1979, 2006) Y - four digit year (Ex. 1979, 2006) y - two digit year (Ex. 79, 06) TIME a - am or pm A - AM or PM B - Swatch Internet time (000 - 999) g - 12 hour (1-12) G - 24 hour c (0-23) h - 2 digit 12 hour (01-12) H - 2 digit 24 hour (00-23)

i - 2 digit minutes (00-59) s 0 2 digit seconds (00-59) OTHER e - timezone (Ex: GMT, CST) I - daylight savings (1=yes, 0=no) O - offset GMT (Ex: 0200) Z - offset in seconds (-43200 - 43200) r - full RFC 2822 formatted date

You might also like