Set the time for a DateTime object.
<?php $date=date_create(“2013-05-01”); date_time_set($date,13,24); echo date_format($date,“Y-m-d H:i:s”); ?> |
The date_time_set() function sets the time for a DateTime object.
date_time_set(object, hour, minute, second, microseconds) |
Parameter |
Description |
object |
Required. Specifies a DateTime object created by date_create(). |
hour |
Required. Specifies the hour for the time. |
minute |
Required. Specifies the minute for the time. |
second |
Optional. Specifies the second for the time; defaults to 0. |
microseconds |
Optional. Specifies the microsecond for the time; defaults to 0. |
Return Value: |
Returns a DateTime object on success; FALSE on failure. |
PHP Version: |
5.2+ |
PHP Changelog: |
PHP 7.1: Added the microseconds parameter. PHP 5.3: Changed the return value from NULL to DateTime. |