In this article, you will learn how to set the date and time function. The date_time_set() function sets the time according to the specified details. But, yes, that will take some time to absorb the things.
What is the syntax of the date_time_set() function in PHP?
date_time_set(object, hour, minute, second, microseconds)
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 |
Examples of the date_time_set() function
Example 1.
<?php
$d=date_create("2014-06-02");
date_time_set($d,11,30);
echo date_format($d,"Y-m-d H:i:s");
?>