Hàm date_time_set () trong PHP
Thí dụ
Đặt thời gian:
<?php
$date=date_create("2013-05-01");
date_time_set($date,13,24);
echo date_format($date,"Y-m-d H:i:s");
?>
Định nghĩa và Cách sử dụng
Hàm date_time_set () đặt thời gian.
Cú pháp
date_time_set(object, hour, minute, second, microseconds)
Giá trị tham số
Parameter | Description |
---|---|
object | Required. Specifies a DateTime object returned by date_create() |
hour | Required. Specifies the hour of the time |
minute | Required. Specifies the minute of the time |
second | Optional. Specifies the second of the time. Default is 0 |
microseconds | Optional. Specifies the microsecond of the time. Default is 0 |
Chi tiết kỹ thuật
Giá trị trả lại: | Trả về một đối tượng DateTime khi thành công. FALSE khi thất bại |
---|---|
Phiên bản PHP: | 5,2+ |
PHP Changelog: | PHP 7.1: Đã thêm tham số micro giây PHP 5.3: Đã thay đổi giá trị trả về từ NULL thành DateTime |
❮ Tham chiếu ngày / giờ PHP