Are there any other methods besides date_default_timezone_set() to handle timezone settings in PHP?
When working with timezones in PHP, besides using the `date_default_timezone_set()` function, you can also set the timezone directly in the `DateTime` object or use the `ini_set()` function to set the timezone globally for the PHP script.
// Set timezone directly in DateTime object
$date = new DateTime();
$date->setTimezone(new DateTimeZone('America/New_York'));
// Set timezone globally using ini_set()
ini_set('date.timezone', 'America/New_York');
Related Questions
- How can PHP functions like mysql_query and mysql_fetch_row be used to retrieve results from a MySQL query?
- What steps can be taken to troubleshoot and resolve PHP include path issues in a web application?
- What are the potential pitfalls of using srand() and shuffle() functions multiple times in PHP code?