Home >>PHP Date Time Functions >PHP date_create() Function
The date_create() function is used to returns a new DateTime object. It accepts two optional parameters $time and $timezone.
Syntax:
date_create($time, $timezone);
Parameter | Description |
---|---|
time | This is an optional parameter. This parameter defines a date/time string. |
timezone | This is an optional parameter. This parameter defines the timezone of time. |
Here is an example of date_create() function in PHP:
<html> <body> <?php $date=date_create(); echo date_format($date,"d-M-Y"); ?> </body> </html>
Here is another example of date_create() function in PHP:
<html> <body> <?php $date=date_create("14-02-2020"); echo date_format($date,"d-M-Y (D)"); ?> </body> </html>