Hàm date_timezone_set () trong PHP
Thí dụ
Đặt múi giờ cho đối tượng DateTime:
<?php
$date=date_create("2013-05-25",timezone_open("Indian/Kerguelen"));
echo date_format($date,"Y-m-d H:i:sP");
?>
Định nghĩa và Cách sử dụng
Hàm date_timezone_set () đặt múi giờ cho đối tượng DateTime.
Cú pháp
date_timezone_set(object, timezone)
Giá trị tham số
Parameter | Description |
---|---|
object | Required. Specifies a DateTime object returned by date_create(). This function modifies this object |
timezone | Required. Specifies a DateTimeZone object that represents the desired time zone. Tip: Look at a list of all supported timezones in PHP |
Chi tiết kỹ thuật
Giá trị trả lại: | Trả về đối tượng DateTime cho chuỗi phương thức. FALSE khi thất bại |
---|---|
Phiên bản PHP: | 5,2+ |
Changelog: | PHP 5.3: Đã thay đổi giá trị trả về từ NULL thành DateTime (khi thành công) |
❮ Tham chiếu ngày / giờ PHP