PHP Set Date

In this example we will explain about PHP set date function.

 
 

Share on Google+Share on Google+

PHP Set Date

Ads

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);

?>

Advertisements

Ads

Posted on: August 25, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles