F.9. Date and Time

FunctionReturnsDescription
time(void)
intReturns current UNIX timestamp.
mktime(int hour, int min, int sec, int mon, int day, int year)
intGets UNIX timestamp for a date.
gmmktime(int hour, int min, int sec, int mon, int day, int year)
intGets UNIX timestamp for a GMT date.
date(string format [, int timestamp])
stringFormats a local time/date.
gmdate(string format [, int timestamp])
stringFormats a GMT/UTC date/time.
idate(string format [, int timestamp])
intFormats a local time/date as integer.
localtime([int timestamp [, bool associative_array]])
arrayReturns the results of the C system call local time as an associative array if the associative_array argument is set to 1 (otherwise it's a regular array).
getdate([int timestamp])
arrayGets date/time information.
checkdate(int month, int day, int year)
boolReturns true(1) if it is a valid date in Gregorian calendar.
strftime(string format [, int timestamp])
stringFormats a local time/date according to locale settings.
gmstrftime(string format [, int timestamp])
stringFormats a GMT/UTC time/date according to locale settings.
strtotime(string time, int now)
intConverts string representation of date and time to a timestamp.
microtime(void)
stringReturns a string containing the current time in seconds and microseconds.
gettimeofday(void)
arrayReturns the current time as array.
getrusage([int who])
arrayReturns an array of usage statistics.
date_sunrise(mixed time [, int format [, float latitude [, float longitude ...

Get Web Standards Programmer's Reference: HTML, CSS, JavaScript®, Perl, Python®, and PHP 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.