SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: PHP Date class

  1. #1
    SitePoint Member
    Join Date
    Dec 2005
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP Date class

    Hi
    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:
    $date=new Date();
    I get an error saying class Date not found.

    I wonder if somebody could tell me how I can make use of this class.

    Many thanks
    Carol

  2. #2
    SitePoint Addict webaddictz's Avatar
    Join Date
    Feb 2006
    Location
    Netherlands
    Posts
    295
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by c_mike View Post
    I get an error saying class Date not found.
    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.
    Yes, I blog, too.

  3. #3
    @php.net Salathe's Avatar
    Join Date
    Dec 2004
    Location
    Edinburgh
    Posts
    1,397
    Mentioned
    64 Post(s)
    Tagged
    0 Thread(s)
    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.
    Salathe
    Software Developer and PHP Manual Author.

  4. #4
    SitePoint Member
    Join Date
    Dec 2005
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi
    Thank you all. Now I understand. It helped


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •