Home >>PHP Date Time Functions >PHP gmmktime() Function

PHP gmmktime() Function

PHP gmmktime() Function

PHP gmmktime() function is used to return the Unix timestamp for a GMT date. It accepts $hour, $minute, $second, $month, $day, $year and $is_dst as parameters. It returns an integer Unix timestamp as output on success or False on error.

Syntax:

gmmktime(hour, minute, second, month, day, year, is_dst);

Parameter Values

Parameter Description
hour This is an optional parameter. This parameter defines the hour.
minute This is an optional parameter. This parameter defines the minute.
second This is an optional parameter. This parameter defines the second.
month This is an optional parameter. This parameter defines the month.
day This is an optional parameter. This parameter defines the day.
year This is an optional parameter. This parameter defines the year.
  This is an optional parameter. This parameters always represent a GMT date so is_dst doesn't influence the result.

Here is an example of gmmktime() function in PHP:

<html>
<body>
<?php
echo date("d-m-Y H:i:s", gmmktime(12,45,55,06,10,2020));
?>
</body>
</html>
Output:
10-06-2020 12:45:55

Example 2:

<html>
<body>
<?php
$date =  gmmktime(12,45,55,6,10,2020);
echo date("d-m-Y H:i:s",$date)."<br>";
echo date("d-m-Y",$date)."<br>";
echo date("j-M-Y",$date)."<br>";
echo date("jS F, Y (l)",$date)."<br>";
echo date("H:i:s dS M, Y",$date)."<br>";
?>
</body>
</html>
Output:
10-06-2020 12:45:55
10-06-2020
10-Jun-2020
10th June, 2020 (Wednesday)
12:45:55 10th Jun, 2020

No Sidebar ads