« | Home | »

PHP date — Format a local time/date

By Martin English | June 17, 2005

string date ( string format [, int timestamp] )
$hh = date(“H”);
if ($hh > “11″) { after_midday() };


Fmt Description
DAY ===========================================================
d Day of the month, 2 digits with leading zeros
D A textual representation of a day, three letters
j Day of the month without leading zeros
l A full textual representation of the day of the week
S English ordinal suffix for the day of the month, 2 characters
w Numeric representation of the day of the week
z The day of the year (starting from 0)

WEEK ==========================================================
W ISO-8601 week number of year, weeks starting on Monday (added in PHP 4.1.0)

MONTH =========================================================
F A full textual representation of a month, such as January or March
m Numeric representation of a month, with leading zeros
M A short textual representation of a month, three letters
n Numeric representation of a month, without leading zeros
t Number of days in the given month

YEAR ==========================================================
L Whether it's a leap year
Y A full numeric representation of a year, 4 digits
y A two digit representation of a year

TIME ==========================================================
a Lowercase Ante meridiem and Post meridiem
A Uppercase Ante meridiem and Post meridiem
B Swatch Internet time
g 12-hour format of an hour without leading zeros
G 24-hour format of an hour without leading zeros
h 12-hour format of an hour with leading zeros
H 24-hour format of an hour with leading zeros
i Minutes with leading zeros
s Seconds, with leading zeros

TIMEZONE ======================================================
I Whether or not the date is in daylights savings time
O Difference to Greenwich time (GMT) in hours
T Timezone setting of this machine
Z Timezone offset in seconds. Zones west of UTC are negative, east are positive.

FULL DATETIME =================================================
c ISO 8601 date (added in PHP 5)
r RFC 2822 formatted date
U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT)

Topics: Code, Languages, Technology, Work | No Comments »

Comments

  • SAP Search

    Custom Search
    Add to Google
  • Recent Posts

  •  

    June 2005
    M T W T F S S
    « May   Jul »
     12345
    6789101112
    13141516171819
    20212223242526
    27282930  
  • Archives