You are here: Home // Date and Time functions
strtotime
(PHP3 >= 3.0.12, PHP4 >= 4.0b2)
strtotime – Parse about any english textual datetime description into a UNIX timestamp
Description
int strtotime (string time [, int now])
The function expects to be given a string containing an english date format and will try to parse that format into a UNIX timestamp.
Example 1. Strtotime() example
echo
time
(PHP3 , PHP4 )
time – Return current UNIX timestamp
Description
int time(void);
Returns the current time measured in the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT).
See also date().
strftime
(PHP3 , PHP4 )
strftime – Format a local time/date according to locale settings
Description
string strftime (string format [, int timestamp])
Returns a string formatted according to the given format string using the given timestamp or the current local time if no timestamp is given. Month and weekday names and other language dependent strings respect the current
mktime
(PHP3 , PHP4 )
mktime – Get UNIX timestamp for a date
Description
int mktime (int hour, int minute, int second, int month, int day, int year [, int is_dst])
Warning: Note the strange order of arguments, which differs from the order of arguments in a regular UNIX mktime() call and which does not lend itself well to leaving out parameters from right to left (see below).
microtime
(PHP3 , PHP4 )
microtime – Return current UNIX timestamp with microseconds
Description
string microtime(void);
Returns the string “msec sec” where sec is the current time measured in the number of seconds since the Unix Epoch (0:00:00 January 1, 1970 GMT), and msec is the microseconds part. This function is only available on operating systems that support
localtime
(PHP4 >= 4.0RC2)
localtime – Get the local time
Description
array localtime ([int timestamp [, bool is_associative]])
The localtime() function returns an array identical to that of the structure returned by the C function call. The first argument to localtime() is the timestamp, if this is not given the current time is used. The second argument to the
gmstrftime
(PHP3 >= 3.0.12, PHP4 >= 4.0RC2)
gmstrftime – Format a GMT/CUT time/date according to locale settings
Description
string gmstrftime (string format, int timestamp)
Behaves the same as strftime() except that the time returned is Greenwich Mean Time (GMT). For example, when run in Eastern Standard Time (GMT -0500), the first line below prints “Dec 31 1998 20:00:00″,
gmmktime
(PHP3 , PHP4 )
gmmktime – Get UNIX timestamp for a GMT date
Description
int gmmktime (int hour, int minute, int second, int month, int day, int year [, int is_dst])
Identical to mktime() except the passed parameters represents a GMT date.
gmdate
(PHP3 , PHP4 )
gmdate – Format a GMT/CUT date/time
Description
string gmdate (string format, int timestamp)
Identical to the date() function except that the time returned is Greenwich Mean Time (GMT). For example, when run in Finland (GMT +0200), the first line below prints “Jan 01 1998 00:00:00″, while the second prints “Dec 31 1997 22:00:00″.
Example
gettimeofday
(PHP3 >= 3.0.7, PHP4 >= 4.0b4)
gettimeofday – Get current time
Description
array gettimeofday (void)
This is an interface to gettimeofday(2). It returns an associative array containing the data returned from the system call.
“sec” – seconds
“usec” – microseconds
“minuteswest” – minutes west of Greenwich
“dsttime”















































