timezone_location_get()函数是PHP中的一个内置函数,用于返回给定时区的位置信息。date time对象作为参数发送给timezone_location_get()函数,成功时返回与时区相关的位置信息,失败时返回False。
null
语法:
timezone_location_get( $object )
参数: 此函数接受单个参数 $object 这是强制性的。它用于指定DateTimeZone对象。
返回值: 此函数在成功时返回给定时区的位置信息,在失败时返回False。
例外情况: timezone_location_get()函数是DateTimeZone::getLocation()函数的别名。
下面的程序演示了PHP中的timezone_location_get()函数:
项目1:
<?php // Opening a timezone $timeZone = timezone_open( "Asia/Kolkata" ); // Displaying the location details of a timezone echo "Location Details of the Specified Timezone: " ; print_r(timezone_location_get( $timeZone )); ?> |
输出:
Location Details of the Specified Timezone: Array ( [country_code] => IN [latitude] => 22.53333 [longitude] => 88.36666 [comments] => )
项目2:
<?php // Declaring a timezone $timeZone = new DateTimeZone( "Asia/Kolkata" ); // Displaying the location details of a timezone echo ( "Location Details of the Specified Timezone:" ); print_r( $timeZone ->getLocation()); ?> |
输出:
Location Details of the Specified Timezone: Array ( [country_code] => IN [latitude] => 22.53333 [longitude] => 88.36666 [comments] => )
相关文章:
参考: http://php.net/manual/en/function.timezone-location-get.php
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END