Programming Basics

  Home arrow Programming Basics arrow PHP`s Calendar Package

PHP`s Calendar Package
By: Apress Publishing
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating:  stars stars stars stars stars / 0

    Table of Contents:
  • PHP`s Calendar Package
  • Calendar Fundamentals



    PHP`s Calendar Package

    (Page 1 of 2 )

    In this fourth part of an eight-part article series on working with date and time functions in PHP, you'll get an introduction to the Calendar package, which can help you handle many chronological tasks automatically. This article is excerpted from chapter 12 of the book Beginning PHP and PostgreSQL 8: From Novice to Professional, written by W. Jason Gilmore and Robert H. Treat (Apress; ISBN: 1590595475).

    Creating a Calendar 

    The Calendarpackage consists of 12 classes capable of automating numerous chronological tasks. The following list highlights just a few of the useful ways in which you can apply this powerful package:

    1. Render a calendar of any scope (hourly, daily, weekly, monthly, and yearly being the most common) in a format of your choice.
    2. Navigate calendars in a manner reminiscent of that used by the Gnome Calendar and Windows Date & Time Properties interface.
    3. Validate any date. For example, you can useCalendarto determine whether April 1, 2019 falls on a Monday (it does).
    4. ExtendCalendarís capabilities to tackle a variety of other tasks, date analysis for instance.

    In this section, youíll learn aboutCalendarís most important capabilities, followed by several examples showing you how to actually implement some of these interesting features. But before you can begin taking advantage of this powerful package, you need to install it. Although you learned all about the PEAR package installation process in Chapter 11, for those of you not yet entirely familiar with the installation process, the necessary steps are reproduced next.

    Installing Calendar

    To capitalize upon all ofCalendarís features, you also need to install theDatepackage. Letís take care of both during theCalendarinstallation process, which follows:

    %>pear install Date
    downloading Date-1.4.3.tgz ...
    Starting to download Date-1.4.3.tgz (42,048 bytes)
    ............done: 42,048 bytes
    install ok: Date 1.4.3
    %>pear install -f Calendar
    Warning: Calendar is state 'beta' which is less stable than state 'stable'
    downloading Calendar-0.5.2.tgz ...
    Starting to download Calendar-0.5.2.tgz (60,164 bytes)
    ..............done: 60,164 bytes
    Optional dependencies:
    package `Date' is recommended to utilize some features.
    install ok: Calendar 0.5.2

    The -fflag is included when installingCalendarhere because, at the time of this writing,Calendaris still a beta release. By the time of publication,Calendar could be officially stable, meaning you wonít need to include this flag. See Chapter 11 for a complete introduction to PEAR and theinstallcommand.

    More Programming Basics Articles
    More By Apress Publishing

    blog comments powered by Disqus


    - The Transliteration Operator in Perl
    - Perl String Processing Functions
    - Perl String Processing
    - Control Flow Constructs: Loops Conclusion
    - Loop Control Constructs
    - Control Flow Constructs: the For and Foreach...
    - Loops and Control Flow Constructs
    - Expression Modifiers for Perl Control Flow C...
    - Logical Operators and Control Flow Constructs
    - Comparing Strings with Control Flow Construc...
    - Perl Operators and Control Flow Constructs
    - Control Flow Constructs
    - More Time Manipulation with PHP
    - Validating and Manipulating Dates with PHP
    - Using the Date Constructor in PHP

    Developer Shed Affiliates


    © 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap