Date/Time Functions

PHP provides the following functions for working with dates and times:

bool checkdate(int month, int day, int year)

Validate a date/time

string date(string format[, int timestamp])

Format a local date/time

array getdate([int timestamp])

Get date/time information

array gettimeofday(void)

Return the current time as array

string gmdate(string format[, int timestamp])

Format a GMT/CUT date/time

int gmmktime(int hour, int min, int sec, int mon, int mday, int year)

Get Unix timestamp for a GMT date

string microtime(void)

Return a string containing the current time in seconds and microseconds

int mktime(int hour, int min, int sec, int mon, int mday, int year)

Get Unix timestamp for a date

void sleep(int seconds)

Delay for a given number of seconds

string strftime(string format[, int timestamp])

Format a local time/date according to locale settings

int time(void)

Return current Unix timestamp

void usleep(int micro_seconds)

Delay for a given number of microseconds

Get Webmaster in a Nutshell, Second 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.