0 ) if( strcmp($t,substr(date("G:i:s"),0,strlen($t))) == 0 || strcmp($t,substr(date("H:i:s"),0,strlen($t))) == 0 ) return true; } return false; } //----------------------------------------------------- // InsertDate() // - - - - - - // Prints the current date. // // $offset - Hours difference between the displayed // date and the web server's date. // $format - "SHORT" or "LONG". //----------------------------------------------------- function InsertDate($offset=0, $format="long") { $kHour = 60*60; if( strcasecmp($format,"long") == 0 ) print date("l, F j, Y",time()+$offset*$kHour); else print date("m/d/y",time()+$offset*$kHour); } //----------------------------------------------------- // ShowDate($begin,$end) // - - - - - - - - // Returns true if the current date and time is after // or including $begin and before $end. // // Both $begin and $end should be formatted as: // "m/d/y[@H[:i[:s]]]" // // If $begin equals 0 or "*", the function returns true // if the current date is before $end. // // If $end equals 0 or "*", the function returns true // if the current date is after $begin. // // // Example: ShowDate("1/1/00","1/1/01") returns true // during the year 2000. //----------------------------------------------------- function ShowDate( $begin, $end = 0 ) { if( $end == 0 ) { $list = explode(" ",trim($begin)); $begin = $list[0]; $end = $list[sizeof($list)-1]; if( $end == "" ) $end = 0; } $list = array( "begin", "end" ); while( list($key,$value) = each($list) ) { if( is_string( $$value ) && strcmp($$value,"*") != 0 ) { list($date,$time) = explode("@",$$value); list($month,$day,$year) = explode("/",$date); list($hour,$min,$sec) = explode(":",$time); $$value = mktime($hour,$min,$sec,$month,$day,$year<80 ? 2000+$year : $year); } else if( is_string( $$value ) && strcmp($$value,"*") == 0 ) $$value = 0; } return( $begin <= time() && ($end == 0 || time() < $end) ); } //----------------------------------------------------- // HideDate($begin,$end) // - - - - - - - - // Returns false if the $begin <= current date < $end. // // See: ShowDate(). //----------------------------------------------------- function HideDate( $begin, $end ) { return !ShowDate($begin,$end); } //----------------------------------------------------- // InsertCountdown($dateTime) // - - - - - - - - // Prints the number of weeks, days, hours, and minutes // between the current time() and $dateTime. // // $dateTime should be formatted as: // "m/d/y[@H[:i[:s]]]" // // Example: Countdown to Halloween Festivities! // InsertCountdown("10/31/2000@19:30") //----------------------------------------------------- function InsertCountdown( $dateTime, $sWeek = "Week", $sDay = "Day", $sHour = "Hour", $sMin = "Minute", $sSec = "" ) { print Countdown( $dateTime, $sWeek, $sDay, $sHour, $sMin, $sSec ); } //----------------------------------------------------- // Countdown($dateTime) // - - - - - - - - // Returns a string representing the difference between // the current time and the input time. // // $dateTime should be formatted as: // "m/d/y[@H[:i[:s]]]" // // Example: Countdown to Halloween Festivities! // InsertCountdown("10/31/2000@19:30") //----------------------------------------------------- function Countdown( $dateTime, $sWeek = "Week", $sDay = "Day", $sHour = "Hour", $sMin = "Minute", $sSec = "" ) { $kSec = 1; $kMin = 60*$kSec; $kHour = 60*$kMin; $kDay = 24*$kHour; $kWeek = 7*$kDay; list($date,$time) = explode("@",$dateTime); list($month,$day,$year) = explode("/",$date); list($hour,$min,$sec) = explode(":",$time); $inTime = mktime($hour,$min,$sec,$month,$day,$year<80 ? 2000+$year : $year); $time_difference = abs(time()-$inTime); $weeks = ( empty($sWeek) ? 0 : floor($time_difference / $kWeek) ); $time_difference -= $weeks * $kWeek; $days = ( empty($sDay) ? 0 : floor($time_difference / $kDay) ); $time_difference -= $days * $kDay; $hours = ( empty($sHour) ? 0 : floor($time_difference / $kHour) ); $time_difference -= $hours * $kHour; $mins = ( empty($sMin) ? 0 : floor($time_difference / $kMin) ); $time_difference -= $mins * $kMin; $secs = ( empty($sSec) ? 0 : floor($time_difference / $kSec) ); $out = ( $weeks == 0 ? "" : "$weeks $sWeek" . ($weeks>1?"s":"") ); $out .= ( $days == 0 ? "" : (empty($out)?"":", ") . "$days $sDay" . ( $days>1?"s":"") ); $out .= ( $hours == 0 ? "" : (empty($out)?"":", ") . "$hours $sHour" . ($hours>1?"s":"") ); $out .= ( $mins == 0 ? "" : (empty($out)?"":", ") . "$mins $sMin" . ( $mins>1?"s":"") ); $out .= ( $secs == 0 ? "" : (empty($out)?"":", ") . "$secs $sSec" . ( $secs>1?"s":"") ); print $out; } //----------------------------------------------------- // InsertDay() // - - - - - - // Prints the day of the week. // // $offset - Hours difference between the displayed // day and the web server's day. // $format - "SHORT" or "LONG". //----------------------------------------------------- function InsertDay($offset=0, $format="long") { $kHour = 60*60; if( strcasecmp($format,"long") == 0 ) print date("l",time()+$offset*$kHour); else print date("D",time()+$offset*$kHour); } //----------------------------------------------------- // ShowDay($days) // - - - - - - - - // Returns true if today is in the list of days. // // $days should be formatted: // "day1 day2 day3 ..." // // i.e.: // "MON TUE WED" //----------------------------------------------------- function ShowDay( $days ) { if( !is_array($days) ) $days = explode(" ",$days); while( $day = each($days) ) { $d = trim($day[value]); if( strlen($d) > 0 && stristr(date("l"),$d) ) return true; } return false; } //----------------------------------------------------- // HideDay($days) // - - - - - - - - // Returns false if today is in the list of days. // // $day should be formatted: // "day1 day2 day3 ..." // // i.e.: // "MON TUE WED" //----------------------------------------------------- function HideDay( $days ) { return !ShowDay($days); } ?>