I have done a little experiment on php's DateTime class. In the documentation they have suggested the syntax for creating the object of DateTime class as given.
Object oriented style:
public DateTime::__construct() ( [ string $time = "now" [, DateTimeZone $timezone = NULL ]] )
DateTime date_create ( [ string $time = "now" [, DateTimeZone $timezone = NULL ]] )
Returns new DateTime object.
Here the first argument they have specified as mandatory, as a date/time string as specified in Date and Time Formats section. Or we have to pass
NULL here to obtain the current time when using the $timezone parameter.
But my problem is when I am giving following code:
date_default_timezone_set('America/Los_Angeles'); $d_ob = new DateTime('x'); echo $d_ob->format('Y-m-d');
It's supposed to generate exception, but it's echoing the current date time like -
I am not getting the point, how it's working?