Here's what I understand:
The DateTime class returns a date. Is it a superglobal? I get the impression that it's systemic, so what's the term you use to describe it?
When you invoke the DateTime class, what is being returned? If I do this:
$date = new DateTime();
//echo $date->format("Y-m-d");
echo $date;
I get an error that says the object of class DateTime could not be converted to a string. That tells me that DateTime by itself has to massaged in order for it to be used programmatically. From what I can tell, you have to format it in order for it to resonate as accurate syntax.
I've looked at the manual, but I'm still coming up short. I'm working in a .NET shop and I'm seeing several instances where some well meaning programmers have invoked the DateTime class, but they've not formatted it correctly which has led to several errors. I want to be able to explain why it's failing in conjunction with coding it correctly.
So, what is the DateTime class and why is it that you have to format it in order to be able to echo it / use it in other functionality?
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.