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 an 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 gmstrftime(string format[, int timestamp])

Format a GMT/CUT time/date according to local settings

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

string strftime(string format[, int timestamp])

Format a local time/date according to local settings

int time(void)

Return current Unix timestamp

Get PHP Pocket Reference 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.