Name

idate

Synopsis

int idate(string format[, int timestamp])

Formats a time and date as an integer according to the format string provided in the first parameter. If the second parameter is not specified, the current time and date is used. The following characters are recognized in the format string:

B

Swatch Internet time

d

Day of the month

h

Hour in 12-hour format

H

Hour in 24-hour format

i

Minutes

I

1 if Daylight Savings Time; 0 otherwise

j

Day of the month; e.g., 1 through 31

L

0 if the year is not a leap year; 1 if it is

m

Month (1 through 12)

s

Seconds

t

Number of days in the month, from 28 to 31

U

Seconds since the Unix epoch

w

Numeric day of the week, starting with 0 for Sunday

W

Numeric week of the year according to ISO 8601

Y

Year with four digits; e.g., 1998

y

Year with one or two digits; e.g., 98

z

Day of the year, from 1 through 365

Z

Time zone offset in seconds, from −43200 (far west of UTC) to 43200 (far east of UTC)

Any characters in the format string not matching one of the above are ignored. Although the character strings used in idate are similar to those in date, because idate returns an integer, in places where date would return a two-digit number with leading zero, the leading zero is not preserved; for example, date('y'); will return 05 for a timestamp in 2005, while idate('y'); will return 5.

Get Programming PHP, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.