Anonymous user / 3.149.234.141 Log In Register
?
Wallet: 3.00
Daily Credits:
1.20 / 1.20

PHP Functions Online


DateTime::setTime

(PHP 5 >= 5.2.0)

DateTime::setTime -- date_time_setSets the time

public DateTime $object->setTime(int $hour , int $minute[, int $second = 0])
public DateTime::__construct([string $time = "now"[, DateTimeZone $timezone = NULL]])
public DateTimeZone::__construct(string $timezone)

Checkout ? #

Item Description Item Price Your Price
Total

Preview #

${{ variable.param.name }} = {{ variable.param|getValue:variable.form:true }};
{{ call.result}} = ;

Tip: You can change some values by clicking on it in the preview above.

Description #

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

Resets the current time of the DateTime object to a different time.

Parameters #

hour

Hour of the time.

minute

Minute of the time.

second

Second of the time.

Return Values #

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

Examples #

Example #1 DateTime::setTime() example

Object oriented style

<?php
$date 
= new DateTime('2001-01-01');

$date->setTime(1455);
echo 
$date->format('Y-m-d H:i:s') . "\n";

$date->setTime(145524);
echo 
$date->format('Y-m-d H:i:s') . "\n";
?>

Procedural style

<?php
$date 
date_create('2001-01-01');

date_time_set($date1455);
echo 
date_format($date'Y-m-d H:i:s') . "\n";

date_time_set($date145524);
echo 
date_format($date'Y-m-d H:i:s') . "\n";
?>

The above examples will output something similar to:

2000-01-01 14:55:00
2000-01-01 14:55:24

Changelog #

Version Description
5.3.0 Changed the return value on success from NULL to DateTime.

See Also #