PHP date_create() Function

What is a Date Create Function?


The "date_create()" function is used to return a new Date Time Object.


date_create ([string $time= "now" [,DateTimeZone $timezone= NULL]])

The default value for "time" is now, timezone is the value of the time.

Example :

date_default_timezone_set ("America/New_York");
$datetime = date_create('12/15/2007');
$date_object->modify("+5 day");
echo $date_object->format("Y-m-d");
Result :


In the above date_create() example the timezone is set to "America/New_York", here the date object is created adding 5 days to the existing date.
Note: (PHP 5 >= 5.2.0)

PHP Topics

Ask Questions

Ask Question