Home Tutorial Php Phpdate PHP Set Date

 
 

Share on Google+Share on Google+
PHP Set Date
Posted on: August 25, 2009 at 12:00 AM
Advertisement
In this example we will explain about PHP set date function.

DateTime::setDate

DateTime::setDate alias date_date_set function is used for resetting the current date of the DateTime object to a different date. It returns the modified DateTime.

Description

public DateTime DateTime::setDate ( int $year, int $month, int $day )
DateTime date_date_set ( DateTime $object, int $year, int $month, int $day )

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

Parameters

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

year - Year of the date.

month - Month of the date.

day - Day of the date.

Examples

<?php
date_default_timezone_set('India/Kolkata');

$datetime = new DateTime('2009-08-24 11:58:10');
$datetime->setDate(2009, 09, 07);

echo $datetime->format(DATE_RFC2822);

?>

Advertisement

Related Tags for PHP Set Date:


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 25, 2009

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com