PHP | mktime() Function Last Updated : 28 Aug, 2018 Comments Improve Suggest changes Like Article Like Report The mktime() function is an inbuilt function in PHP which is used to return the Unix timestamp for a date. The timestamp returns a long integer containing the number of seconds between the Unix Epoch (January 1, 1970, 00:00:00 GMT) and the time specified. The hour, minute, second, month, day and year are sent as parameters to the mktime() function and it returns an integer Unix timestamp on success and False on error. Syntax: int mktime( $hour, $minute, $second, $month, $day, $year, $is_dst) Parameters: This function accepts seven parameters as mentioned above and described below: $hour: It is an optional parameter which specifies the hour. $minute: It is an optional parameter which specifies the minute. $second: It is an optional parameter which specifies the second. $month: It is an optional parameter which specifies the month. $day: It is an optional parameter which specifies the day. $year: It is an optional parameter which specifies the year. $is_dst: It is an optional parameter which can be set to 1 if the time is during daylight savings time (DST), or 0 if it is not. Return Value: This function returns an integer Unix timestamp on success and False on error. Exceptions: PHP 5.3.0 version throws an E_DEPRECATED error if the is_dst parameter is used. The mktime() function throws a E_NOTICE on every call to a date/time if the time zone is not valid. Below programs illustrate the mktime() function in PHP: Program 1: php <?php // Using mktime() function to know the day echo "December 1, 2002 was on a " . date("l", mktime(0, 0, 0, 12, 1, 2002)); ?> Output: December 1, 2002 was on a Sunday Program 2: php <?php // Using mktime() function to know the complete date echo date("M-d-Y", mktime(0, 0, 0, 12, 1, 2002)) . "<br>"; // Using mktime() function to know the // complete date for an out-of-range input echo date("M-d-Y", mktime(0, 0, 0, 12, 40, 2002)); ?> Output: Dec-01-2002Jan-09-2003 Related Articles: PHP | gmdate() Function PHP | time() Function Reference: http://php.net/manual/en/function.mktime.php Comment More infoAdvertise with us Next Article PHP | mktime() Function S Shubrodeep Banerjee Follow Improve Article Tags : Misc Web Technologies PHP PHP-date-time PHP-function +1 More Practice Tags : Misc Similar Reads PHP | gmmktime() Function The gmmktime() function is an inbuilt function in PHP which is used to return the Unix timestamp for a GMT date. The $hour, $minute, $second, $month, $day, $year and $is_dst are sent as parameters to the gmmktime() function and it returns an integer Unix timestamp on success or False on error. Synta 2 min read PHP | hrtime() Function The hrtime() function is an inbuilt function in PHP which returns the high-resolution time of the system. Syntax: mixed hrtime( bool $is_num_return ); Parameter: This function accepts a single parameter as mentioned above and described below: $is_num_return: It is optional parameter of Boolean type. 1 min read PHP | microtime() Function The microtime() function is an inbuilt function in PHP which is used to return the current Unix timestamp with microseconds. The $get_as_float is sent as a parameter to the microtime() function and it returns the string microsec sec by default. Syntax: microtime( $get_as_float ) Parameters: This fun 2 min read PHP | gmstrftime() Function The gmstrftime() function is an inbuilt function in PHP which is used to format a GMT/UTC time/date according to local settings. The gmstrftime() function in PHP behaves in the same way as strftime() except that the time returned by the gmstrftime() function is Greenwich Mean Time (GMT). The $format 2 min read PHP | gmdate() Function The gmdate() is an inbuilt function in PHP which is used to format a GMT/UTC date and time and return the formatted date strings. It is similar to the date() function but it returns the time in Greenwich Mean Time (GMT). Syntax: string gmdate ( $format, $timestamp ) Parameters: The gmdate() function 2 min read Like