Date / Times Procedural

time()

To retrieve a UNIX timestamp use time()

1725974461

mktime()

The mktime() function creates a UNIX time stamp based on integers for the hour, minute, second, month, day and year

61432250

strtotime()

The function strtotime() can be used to create timestamps between December 13 1901 and January 19 2038. The function accepts dates in the format 05 DEC 2012 and 12/05/2013

1367704800

getdate()

Returns an associate array of useful date / time information

Array ( [seconds] => 1 [minutes] => 21 [hours] => 15 [mday] => 10 [wday] => 2 [mon] => 9 [year] => 2024 [yday] => 253 [weekday] => Tuesday [month] => September [0] => 1725974461 )

Formatting Output with date()

Use the date() method to format output.

Thu 31 Jan 1980

Headline format characters

d
Day of the month, 2 digits with leading zeros 01 to 31
D
A textual representation of a day, three letters Mon through Sun
j
Day of the month without leading zeros 1 to 31
l
(lowercase 'L') A full textual representation of the day of the week Sunday through Saturday
F
A full textual representation of a month, such as January or March January through December
m
Numeric representation of a month, with leading zeros 01 through 12
M
A short textual representation of a month, three letters Jan through Dec
n
Numeric representation of a month, without leading zeros 1 through 12
t
Number of days in the given month 28 through 31
Y
A full numeric representation of a year, 4 digits Examples: 1999 or 2003
y
A two digit representation of a year Examples: 99 or 03

Formatting Output with strftime()

Alternatively, use the strftime() method to format output.

25 December 1986

Headline format characters

%a
abbreviated weekday name according to the current locale
%A
full weekday name according to the current locale
%b
abbreviated month name according to the current locale
%B
ull month name according to the current locale
%d
day of the month as a decimal number (range 01 to 31)
%D
same as %m/%d/%y
%e
day of the month as a decimal number, a single digit is preceded by a space (range ' 1' to '31')
%m
month as a decimal number (range 01 to 12)
%y
year as a decimal number without a century (range 00 to 99)
%Y
year as a decimal number including the century