gmmktime

FunctionParams and return types changed in PHP 8.0

Get Unix timestamp for a GMT date.

PHP 5
PHP 7.0
Improved
PHP 7.1-7.4
PHP 8.0
Improved
PHP 8.1
PHP 8.2-8.3
PHP 8.4
PHP 8.5
PHP 8.6

gmmktime Function synopsis

gmmktime(
    int $hour,
    ?int $minute = null,
    ?int $second = null,
    ?int $month = null,
    ?int $day = null,
    ?int $year = null
  ): int|false

Parameters

$hour

Typeint

The number of the hour relative to the start of the day determined by $month, $day and $year. Negative values reference the hour before midnight of the day in question. Values greater than 23 reference the appropriate hour in the following day(s).

$minute

OptionalType?intDefault valuenull

The number of the minute relative to the start of the $hour. Negative values reference the minute in the previous hour. Values greater than 59 reference the appropriate minute in the following hour(s).

$second

OptionalType?intDefault valuenull

The number of seconds relative to the start of the $minute. Negative values reference the second in the previous minute. Values greater than 59 reference the appropriate second in the following minute(s).

$month

OptionalType?intDefault valuenull

The number of the month relative to the end of the previous year. Values 1 to 12 reference the normal calendar months of the year in question. Values less than 1 (including negative values) reference the months in the previous year in reverse order, so 0 is December, -1 is November, etc. Values greater than 12 reference the appropriate month in the following year(s).

$day

OptionalType?intDefault valuenull

The number of the day relative to the end of the previous month. Values 1 to 28, 29, 30 or 31 (depending upon the month) reference the normal days in the relevant month. Values less than 1 (including negative values) reference the days in the previous month, so 0 is the last day of the previous month, -1 is the day before that, etc. Values greater than the number of days in the relevant month reference the appropriate day in the following month(s).

$year

OptionalType?intDefault valuenull

The year

Return value

Typeint|false

Returns a int Unix timestamp on success, or false if the timestamp doesn't fit in a PHP integer.

Changes to the gmmktime Function

PHP 8.0

  • Return type added: int|false
  • Parameter type added for parameter #1 ($hour): int
  • Parameter name of parameter #2 changed: $min to $minute
  • Parameter type added for parameter #2 ($minute): ?int
  • Parameter default value added for position #2 ($minute): null
  • Parameter name of parameter #3 changed: $sec to $second
  • Parameter type added for parameter #3 ($second): ?int
  • Parameter default value added for position #3 ($second): null
  • Parameter name of parameter #4 changed: $mon to $month
  • Parameter type added for parameter #4 ($month): ?int
  • Parameter default value added for position #4 ($month): null
  • Parameter type added for parameter #5 ($day): ?int
  • Parameter default value added for position #5 ($day): null
  • Parameter type added for parameter #6 ($year): ?int
  • Parameter default value added for position #6 ($year): null
  gmmktime(
-     $hour,
+     int $hour,
-     $min,
+     ?int $minute = null,
-     $sec,
+     ?int $second = null,
-     $mon,
+     ?int $month = null,
-     $day,
+     ?int $day = null,
-     $year
+     ?int $year = null
-   )
+   ): int|false

PHP 7.0

  • Parameter count changed: 7 to 6
  • Optional parameter removed - #7: $is_dst
 gmmktime(
     $hour,
     $min,
     $sec,
     $mon,
     $day,
-    $year,
-    $is_dst
+    $year
   )

PHP 5.5

  • Optional parameter added - #7: $is_dst
 gmmktime(
     $hour,
     $min,
     $sec,
     $mon,
     $day,
-    $year
+    $year,
+    $is_dst
   )

gmmktime Function Availability

PHP VersionAvailability
PHP 8.6Upcoming Release Yes
PHP 8.5Supported (Latest) Yes
PHP 8.4Supported Yes
PHP 8.3Security-Fixes Only Yes
PHP 8.2Security-Fixes Only Yes
PHP 8.1Unsupported Yes
PHP 8.0Unsupported Yes
PHP 7.4Unsupported Yes
PHP 7.3Unsupported Yes
PHP 7.2Unsupported Yes
PHP 7.1Unsupported Yes
PHP 7.0Unsupported Yes
PHP 5.6Unsupported Yes
PHP 5.5Unsupported Yes
PHP 5.4Unsupported Yes
PHP 5.3Unsupported Yes