gmmktime


php apg

GETS the UNIX timestamp for a particular GMT/UTC date.



<?php

int
|false gmmktime int $hour 
                          
int|null $minute null 
                          
int|null $second null 
                          
int|null $month null 
                          
int|null $day null 
                          
int|null $year null )


where,

$hour The number of the hour relative to the start of the GMT date

$minute 
The number of the minute relative to the start of the GMT date

$second 
The number of thesecond relative to the start of the GMT date

$month 
The number of the month relative to the end of the previous year

$day 
The number of the day relative to the end of the previous month

$year 
The number of the year

?>

 $hour 


The number of the $hour relative to the start of the GMT date.

$hour is relative to the start of 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 


The number of the $minute relative to the start of the GMT date.

$minute is 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 


The number of the $second relative to the start of the GMT date.

$second is 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 


The number of the $month relative to the end of the previous year.

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



 $day 


The number of the $day relative to the end of the previous month.

$day is relative to the end of the previous $month.
Values 1 to 28, 29, 30 or 31 as referenced as the normal $month.
Values less than 1, (including negative), 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 


The number of the $year.

If $year with values between 0 to 69 maps years between 2000 to 2069.
If $year with values between 70 to 100 maps years between 1970 to 2000.
On systems where time register is a 32bit signed integer, as most common today, the valid range for $year is somewhere between 1901 and 2038.
However, before PHP 5.1.0 this range was limited from 1970 to 2038 on some systems, (e.g. Windows™).



 $isDST 


To control if DST or out of DST.

$isDST can be set to 1 if the time is during daylight savings time, (DST), 0 if it is not, or -1, (the default), if it is unknown whether the time is within daylight savings time or not.
If it's unknown, PHP tries to figure it out itself. This can cause unexpected, (but not incorrect), results.
Some times are invalid if DST is enabled on the system PHP is running on or is_dst is set to 1.
If DST is enabled in e.g. 2:00, all times between 2:00 and 3:00 are invalid and this function returns an undefined, (usually negative), value.
Some systems, (e.g. Solaris 8), enable DST at midnight so time 0:30 of the day when DST is enabled is evaluated as 23:30 of the previous day.

$isDST since PHP 5.1.0 became deprecated.

$isDST support was removed in PHP 7.0.0.




 $hour, $minute, $second, $month, $day & $year 


OPTIONAL PARAMETERS VALUE DEFAULT
$hour idate("H") time()
$minute idate("i")
$second idate("s")
$month idate("m")
$day idate("j")
$year idate("Y")
ed48




The UNIX timestamp corresponding to the arguments given.

This timestamp is a long integer containing the number of seconds between the Unix Epoch, (January 1 1970 00:00:00 GMT) and the time specified.

Like mktime the arguments may be left out in order from right to left; any arguments thus omitted will be set to the current GMT value of date and time.



  1 EXERCISE   

<?php

$lang 
'fr';

$loc_FR '"fr_FR.utf-8", "fr.utf-8", "fra", "french"';
setlocale(LC_ALL"fr_FR.utf-8""fr.utf-8""fra""french");
date_default_timezone_set('UTC');
$tz_gt date_default_timezone_get();

echo 
'TZ:&nbsp;' $tz_gt '<br><br>LOCALE:&nbsp;' $loc_FR '<br><br>';

$gmmktm01 gmmktime(0,0,0,1,1,1970);

$pt 'Inicio da UNIX ERA: ' $gmmktm01 's';
$fr 'Haut de la ERA UNIX: ' $gmmktm01 's';
echo $
$lang '<br><br>';

echo 
gmstrftime('%A, %d %B %Y (%Hh %Mmin %Ss)'$gmmktm01);

$gmmktm02 gmmktime(3,14,7,1,19,2038);

echo 
'<br><br><br><br>';
$pt 'Final da UNIX ERA: 32bit: ' $gmmktm02 's';
$fr 'Fin de la ERA UNIX: 32bit: ' $gmmktm02 's';
echo $
$lang '<br><br>';
echo 
gmstrftime('%A, %d %B %Y (%Hh %Mmin %Ss)'$gmmktm02) . '<br><br>';

?>

  2 EXERCISE   

<?php

// $lang = 'en';
$lang 'pt';

$loc_BR '"pt_BR.utf-8", "portuguese-brazil", "ptb"';
setlocale(LC_ALL"pt_BR.utf-8""portuguese-brazil""ptb"); 
date_default_timezone_set('America/Sao_Paulo');
$tz_nw date_default_timezone_get();

echo 
$tz_nw '<br><br>' $loc_BR '<br><br>';

$gmmkt_t gmmktime(3,14,7,1,19,2038);

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - -
   End of UNIX 32 bit ERA
   - - - - - - - - - - - - - - - - - - - - - - - - - - - */

$pt 'Data testada: ' $gmmkt_t;
$en 'Tested date: ' $gmmkt_t;
echo $
$lang '<br><br>';

echo 
gmstrftime('%A, %d %B %Y (%Hh %Mmin %Ss)'$gmmkt_t);


/* - - - - - - - - - - - - - - - - - - - - - - - - - - - -
   PLEASE NOTE THAT no matter the timezone,
   dates will always be considered in relation to GMT.
   
   gmstrftime:
   This function may have problems displaying 
   characters in languages other than english.
   - - - - - - - - - - - - - - - - - - - - - - - - - - - */
   
?>