• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 211
  • Last Modified:

return date and classify as season

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?
0
redcable
Asked:
redcable
  • 2
1 Solution
 
captaincarlCommented:
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";
       break;
    case "June":
       $season = "summer";
       break;
    case "October":
       $season = "fall";
       break;
  }
  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!
0
 
captaincarlCommented:
Whops, that should be ``$tmp = strftime( "%m" );'' in the second example.
0
 
sfinktahCommented:
As amazing is this might occur to non-Americans, the seasons actually vary depending on where you live.  ;-)

Cyrus
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now