I am new to PHP5 Object Oriented Programming. I came across the ‘Date’ class in PHP5(book i am referring:Beginning PHP and MySQL 5 From Novice to Professional by W Jason Gilmore, 2006).
The book says that the Date and Time extension has been incorporated into the standard PHP distribution as of version PHP5.1. I am using PHP 5.2.0.
When I use the Date class in my code, for instance:
I get an error saying class Date not found.
I wonder if somebody could tell me how I can make use of this class.
Thank you all. Now I understand. It helped
It might be a simple typo, because there is no Date class I know of. There is a DateTime class though, probably that’s what the author meant.
The DateTime extension as it exists today in PHP has improved greatly over the years. The book appears to be referring to the old (circa 2004) PECL “Date and Time” extension (package page) which was moved into PHP and forms the basis of the current DateTime extension.
Also, heed the big, bold warning in the book:
Caution This chapter was written several months ahead of the official PHP 5.1 release, at a time when no documentation was available for the Date extension. Therefore, be forewarned that any information found in this section could indeed be incorrect by the time you read this. Nor does this section offer a comphrehensive summary of all available features, as at the time of writing several of the methods weren’t working properly, and therefore it was decided better to omit them from the material. Such are the risks one takes to stay on the leading edge of technology!
So, use the DateTime class. (: