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.
Syntax:
int gmmktime( $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 is used to specify the hour time.
- $minute: It is an optional parameter which is used to specify the minute.
- $second: It is an optional parameter which is used to specify the second.
- $month: It is an optional parameter which is used to specify the month.
- $day: It is an optional parameter which is used to specify the day.
- $year: It is an optional parameter which is used to specify 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 or False on error.
Exception: PHP 5.3.0 version throws an E_DEPRECATED error if the $is_dst parameter is used.
Below program illustrate the gmmktime() function in PHP:
Program 1:
<?php // Using gmmktime() function to know the day echo "August 30, 2018 was on ". date("l", gmmktime(0, 0, 0, 8, 30, 2018)); ?> |
August 30, 2018 was on Thursday
Program 2:
<?php // Using gmmktime() function to know // the complete date echo date("M-d-Y", gmmktime(0, 0, 0, 12, 1, 2012)) . "<br>"; // Using gmmktime() function to know the // complete date for an out-of-range input echo date("M-d-Y", gmmktime(0, 0, 0, 12, 20, 2017)); ?> |
Dec-01-2012
Dec-20-2017
Related Articles:
Reference: http://php.net/manual/en/function.gmmktime.php
Recommended Posts:
- How to call a function that return another function in JavaScript ?
- How to get the function name from within that function using JavaScript ?
- How to get the function name inside a function in PHP ?
- PHP | max( ) Function
- D3.js | d3.map.set() Function
- D3.js | d3.min() function
- p5.js | box() Function
- PHP | min( ) Function
- CSS | rgb() Function
- PHP | Ds\Map get() Function
- D3.js | d3.hcl() Function
- D3.js | d3.rgb() Function
- p5.js | value() Function
- PHP | dir() Function
- D3.js | d3.lab() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



