PHP date_time_set() Function

Example

Set Time:

<?php
$date=date_create("2016-09-25");
date_time_set($date,12,36);
echo date_format($date,"Y-m-d H:i:s");
?>

Running Example

Definition and Usage

The date_time_set() function is used to set the time.

Syntax

date_time_set(object,hour,minute,second);
Parameters Description
object Required. Specifies by date_create() The returned DateTime object.
hour Required. Specifies the hours in the time.
minute Required. Specifies the minutes in the time.
second Optional. Specifies the seconds in the time. Defaults to 0.

Technical Details

Return Value: Returns a DateTime object on success. Returns FALSE on failure.
PHP Version: 5.2+
Update Log: PHP 5.3.0: The return value changed from NULL to DateTime.