|
|
PHP date_create() Function
|
Tutorials » Php »
|
Topic |
What is a Date Create Function?
|
|
Explanation |
|
The "date_create()" function is used to return a new Date Time Object.
Syntax:
date_create ([string $time= "now" [,DateTimeZone $timezone= NULL]])
The default value for "time" is now, timezone is the value of the time.
Example:
<?php
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:
2007-12-20
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)
|
|
A Note |
Learn PHP programming language tutorial with simple and neat example. Hope you enjoy this free tutorial.
Do give us your valuable feedback and suggestions on this online tutorial. This is a Copyright Content.
|
|
|
|