English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
PHP Date & Time Functions Manual
The gmmktime() function gets the UNIX timestamp of the GMT date
gmmktimeThe function accepts hours, minutes, seconds, month, day, and year as parameters (representing a date) and returns the Unix timestamp for the given GMT date. If no parameters are passed to this method, it will return the current timestamp.
gmmktime($hour, $minute, $second, $month, $day, $year, $is_dst)
Exactly the same as mktime(), except that the return value is the timestamp in Greenwich Mean Time. Parameters always represent GMT dates, so is_dst has no effect on the result. Like mktime(), parameters can be left blank from right to left, and the blank parameters will be set to the corresponding current GMT value.
Serial Number | Parameters and Description |
---|---|
1 | hours(Required) This is an integer value representing the number of hours from the start of each day. |
2 | minute(Required) This is an integer value representing the number of hours from the start of each hour. |
3 | seconds(Optional) This is an integer value representing the number of seconds from the start of each minute. |
4 | month(Required) This is an integer value representing the month of the year, it should be between1to12between. |
5 | day(Required) This is the integer value representing the date, it should be less than the number of days allowed in the given month. |
6 | year(Required) This is the integer value representing the year of the date, it should be between1to32767between. |
7 | is_dst(Required) If the time is during Daylight Saving Time (DST), you can set this parameter to1; If it is not in Daylight Saving Time (DST), you can set this parameter to-1(Default value) |
The PHP gmmktime() function returns a Unix timestamp representing the given date. If it fails, this function returns a boolean valuefalse.
This function was originally introduced in PHP 4Version introduced, and can be used in all higher versions.
The following examples demonstrategmmktime()Function Usage-
<?php $timestamp = gmmktime(); print($timestamp); ?>Test to see‹/›
Output Result
1589392532
Now, let's call the above method by passing all the necessary parameters-
<?php $timestamp = gmmktime(7, 36, 45, 06, 25, 2017); print($timestamp); ?>Test to see‹/›
Output Result
1498376205
Get the number of days in a specific month of a specific year
<?php $lastday = gmmktime(0, 0, 0, 3, 0, 2010); echo strftime("2010year2The last day of the month is: %d\n", $lastday); $lastday = gmmktime(0, 0, 0, 4, -31, 2010); echo strftime("2010year2The last day of the month is: %d, $lastday); ?>Test to see‹/›
This produces the following result-
2010year2The last day of the month is: 28 2010year2The last day of the month is: 28