$date = new DateTime(); $timezone = $date->getTimezone(); echo $timezone->getName();
$date = new DateTime('2022-12-31 23:59:59', new DateTimeZone('Asia/Tokyo')); $timezone = $date->getTimezone(); echo $timezone->getName();In this example, we create a DateTime object with a specific date and time in the 'Asia/Tokyo' timezone. Then, we use the getTimezone method to get the timezone of the DateTime object. Finally, we use the getName method of the DateTimeZone object to get the name of the timezone. Package/library: The DateTime class is a built-in class in PHP, so no additional package/library is required.