Location: PHPKode > projects > XmlWeblication > weblication/modules/season.php
<?php

function module_season() {

  global $aid, $cfg, $app;
  
	
  $now = time();
	
	//$rc  = "Today = " . date("Y-m-d", $now ) . "<br>";
	
	
	$winter_start = strtotime("21 December ". date("Y",$now));
	$spring_start = strtotime("20 March " . date("Y",$now));
	$summer_start = strtotime("21 June ". date("Y",$now));
	$authum_start = strtotime("22 September " . date("Y",$now));
	
  if(	$now > $authum_start) 
	{
	  // We look forward for next spring
		$nextyear = (date("Y",$now) * 1)+1;
		$spring_start = strtotime( "20 March ". $nextyear );
		$diff = $spring_start - $now;
		
		$rc .= "Days getting longer! " . 
		       sprintf("%d seconds/%d hours/%d days until spring!",$diff,$diff/3600,$diff/3600/24);
		
	}
	else {
	  // We countdown to end of summer
		if ( $now < $summer_start ) {
		  $diff = $summer_start - $now;
  		$rc .= "Enjoy Spring and look forward - Summer is on the way ... ".
			  sprintf( "%d seconds/%d hours/%d days", $diff,$diff/3600,$diff/3600/24);
		} else {
		  $diff = $authum_start - $now;
		  $rc .= sprintf( "Enjoy the last %d seconds/%d hours/%d days of this summer", $diff,$diff/3600,$diff/3600/24);
		}
	}
	
/*	$rc .= "<br>Spring " . date("Y-m-d", $spring_start ) . "<br>" .
	       "Summer " . date("Y-m-d", $summer_start ) . "<br>".
				 "Authum " . date("Y-m-d", $authum_start ) . "<br>".
				 "Winter " . date("Y-m-d", $winter_start )  . "<br>";
	*/
  return( $rc );
}



?>
Return current item: XmlWeblication