Home Tutorial Php Phpdate date_time_set

 
 

date_time_set
Posted on: August 27, 2009 at 12:00 AM
Advertisement
date_time_set alias DateTime::setTime function resets the the current time of the DateTime object to a different time. It returns the modified date and time. 

date_time_set

date_time_set alias DateTime::setTime function resets the the current time of the DateTime object to a different time. It returns the modified date and time. 

Syntax

public DateTime DateTime::setTime ( int $hour , int $minute [, int $second ] )
DateTime date_time_set ( DateTime $object , int $hour , int $minute [, int $second ] )

Parameters

object - Procedural style only: A DateTime object returned by date_create()

hour - Hour of the time.

minute - Minute of the time.

second - Second of the time.

Example: Changing the time of a DateTime object

<?php

date_default_timezone_set('India/Delhi');

$datetime = new DateTime('2009-08-25 16:45:36');
echo $datetime->format('Y-m-d H:i:s') . "\n";

$datetime->setTime(13, 35, 12);
echo $datetime->format('Y-m-d H:i:s') . "\n";

$datetime->setTime($datetime->format('H'), $datetime->format('n') + 6);
echo $datetime->format('Y-m-d H:i:s') . "\n";

$datetime->setTime($datetime->format('H') + 12, $datetime->format('n'));
echo $datetime->format('Y-m-d H:i:s') . "\n";
?>

Advertisement

Related Tags for date_time_set:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: August 27, 2009

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com