getdate 


php apg

GETS the date/time information of a specific instant.



<?php

arr getdate 
int|null $timestamp null )


where,

$timestamp The UNIX timestamp

?>

 $timestamp 


The related UNIX timestamp.

The $timestamp has the same value provided by the time function.



 ARRAY INDEX for getdate 

KEY DESCRIPTION EXAMPLE RETURNED
seconds Numeric representation of seconds 0 to 59
minutes Numeric representation of minutes 0 to 59
hours Numeric representation of hours 0 to 23
mday Numeric representation of the day of the month 1 to 31
wday Numeric representation of the day of the week 0 for Sunday
...
6 for Saturday
mon Numeric representation of a month 1 to 12
year A full numeric representation of a year, 4 digits 1998 ... 2019
yday Numeric representation of the day of the year 0 to 365
weekday A full textual representation of the day of the week Sunday ... Saturday
month A full textual representation of a month January ... December
0 Seconds since the Unix Epoch System Dependent
ed48




This function is not compatible with locale, it is only dependent on the TimeZone.

Since PHP 8.0.0 $timestamp is nullable.



  1 EXERCISE   

<?php

setlocale
(LC_ALL"en_US""american""american english""american-english""english-american""english-us""english-usa""enu""us""usa");
date_default_timezone_set('UTC');
$defatz date_default_timezone_get();
$df_getdate getdate();
echo 
$defatz '<br><br>';

echo 
'<pre>';
print_r($df_getdate);
echo 
'<pre><br><br>';

setlocale(LC_ALL"pt_BR.utf-8""portuguese-brazil""ptb"); 
date_default_timezone_set('America/Sao_Paulo');
$newtz date_default_timezone_get();
$br_getdate getdate();
echo 
$newtz '<br><br>';

echo 
'<pre>';
print_r($br_getdate);
echo 
'<pre><br><br>';

/* - - - - - - - - - - - - - - - - - - - - - - - - - -
  
   NOTE that it is useless indicate LOCALE, therefore,
   both results are identical.

   This function is only dependent on the TimeZone.
   
   - - - - - - - - - - - - - - - - - - - - - - - - - - */

?> 

  2 EXERCISE   

<table width="100%" cellspacing="5" cellpadding="5" 
border="1" align="center"><tbody>
<tr><td width="50%">KEY</td><td width="50%">ACTUAL VALUE</td></tr>
<?php

$now 
getdate();

foreach (
$now  as $nw => $n)
{
echo 
'<tr><td>' $nw '</td><td>' $n '</td></tr>';
}

?> 
<tr><td colspan="2">ed48</td></tr></tbody></table>