PHP date_time_set()Functions

PHP Date/TimePHP Date/Time Reference Manual

Examples

Set time:

<?php
$date=date_create("2013-05-01");
date_time_set($date,13,24);
echo date_format($date,"Y-m-d H:i:s");
?>

Run 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 adate_create()DateTime object returned by
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.

Technical Details

Return value: Returns a DateTime object on success. Returns FALSE on failure.
PHP version: 5.2+
Changelog: PHP 5.3.0: Return value changed from NULL to DateTime.


PHP Date/TimePHP Date/Time Reference Manual Other extensions