Funções PHP |
. Glossários Funções PHP - gmmktime ( ) |
int gmmktime ( [int hour [, int minute [, int second [, int month [, int day [, int year [, int is_dst]]]]]]])
Idêntico ao mktime() exceto que os parâmetros passados representam uma data GMT.
Como em mktime(), os argumentos podem ser omitidos da direita para esquerda, com qualquer argumento omitido sendo definido para o valor GMT correspondente.
Exemplo:
<?php
function gmstrtotime($sgm) {
$months = array(
'Jan'=>1,
'Feb'=>2,
'Mar'=>3,
'Apr'=>4,
'May'=>5,
'Jun'=>6,
'Jul'=>7,
'Aug'=>8,
'Sep'=>9,
'Oct'=>10,
'Nov'=>11,
'Dec'=>12
);
list($D, $d, $M, $Y, $H, $i, $s) = sscanf($sgm, "%3s, %2d
%3s %4d %2d:%2d:%2d GMT");
return gmmktime($H, $i, $s, $months[$M], $d, $Y);
}
// test: after all is said and done
// $time should be the same as $gmtime
$time = time();
$us = date("m/d/Y H:i:s",$time);
$sgm = gmdate("D, d M Y H:i:s",$time) . " GMT";
$gmtime = gmstrtotime($sgm);
echo $us . "<BR>";
echo $sgm . "<BR>";
echo $time . "<BR>";
echo $gmtime . "<BR>";
?>
Minha saída :
02/13/2004 10:45:42
Fri, 13 Feb 2004 20:45:42 GMT
1076705142
1076705142