return date and classify as season

Posted on 2004-11-30
Last Modified: 2006-11-17
currently use strftime %B to return the current month in a header. Im looking to write a function that will compare strftime  to a date range so that i can return a date range isntead. for example, fall, summer, spring, winter.

any ideas how best to go about this?
Question by:redcable
    LVL 1

    Accepted Solution

    If you simply want to specify the four seasons, you could fill in the remaining nine months and do something such as the following:

      switch( strftime( "%B" )) {
        case "January":
           $season = "winter";
        case "June":
           $season = "summer";
        case "October":
           $season = "fall";
      print $season;

    Or use the if/else route:

      $tmp = strftime( "%b" );
      if( $tmp == 12 || $tmp <= 3 ) {
        print "winter";
      } elseif( $tmp >= 4 && $tmp <= 6 ) {
        print "spring";

    Hopefully I understood your question correctly. If not, reply and we'll give it another go!
    LVL 1

    Expert Comment

    Whops, that should be ``$tmp = strftime( "%m" );'' in the second example.
    LVL 1

    Expert Comment

    As amazing is this might occur to non-Americans, the seasons actually vary depending on where you live.  ;-)


    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    Suggested Solutions

    Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
    Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit ( and similar technologies have enjoyed wide adoption, making it possib…
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now