DateTime::setTime

PHP 5 >= 5.2.0, PHP 7, PHP 8
DateTime::setTime - Sets the time
Manual
Code Examples

DateTime::setTime( int$hour, int$minute, [int$second = 0], [int$microsecond = 0] ): public DateTime

Procedural style

DateTimedate_time_set DateTimeobject inthour intminute intsecond0 intmicrosecond0

Parameters

object

Procedural style only: A DateTime object returned by date_create. The function modifies this object.

hour

Hour of the time.

minute

Minute of the time.

second

Second of the time.

microsecond

Microsecond of the time.

Return Values

Returns the DateTime object for method chaining or false on failure.

Changelog

Version Description
7.1.0 The microsecond parameter was added.

Related Functions

Example of DateTime::setTime

Show all examples for DateTime::setTime

PHP Version:


Function DateTime::setTime:

Date and Time Functions

Most used PHP functions