The current time and date for a particular time zone can found by setting the time zone and then calling the getdate() function to get a date object.
The program below accesses various members of the associative date array to get all of the aspects of the current date and time. The fields are as follows:
<!DOCTYPE html> <html> <head> </head> <body> <?php date_default_timezone_set('America/Chicago'); $qaDate = getdate(); echo "<h3>Default Time Zone: ".date_default_timezone_get()."</h3>".PHP_EOL; echo "<ul>".PHP_EOL; echo " <li> $qaDate[0] = ".$qaDate[0]."</li>".PHP_EOL; echo " <li> $qaDate['seconds'] = ".$qaDate['seconds']."</li>".PHP_EOL; echo " <li> $qaDate['minutes'] = ".$qaDate['minutes']."</li>".PHP_EOL; echo " <li> $qaDate['hours'] = ".$qaDate['hours']."</li>".PHP_EOL; echo " <li> $qaDate['weekday'] = ".$qaDate['weekday']."</li>".PHP_EOL; echo " <li> $qaDate['wday'] = ".$qaDate['wday']."</li>".PHP_EOL; echo " <li> $qaDate['mday'] = ".$qaDate['mday']."</li>".PHP_EOL; echo " <li> $qaDate['yday'] = ".$qaDate['yday']."</li>".PHP_EOL; echo " <li> $qaDate['month'] = ".$qaDate['month']."</li>".PHP_EOL; echo " <li> $qaDate['mon'] = ".$qaDate['mon']."</li>".PHP_EOL; echo " <li> $qaDate['year'] = ".$qaDate['year']."</li>".PHP_EOL; echo "</ul>".PHP_EOL; ?> </body> </html>
© 20072024 XoaX.net LLC. All rights reserved.