All pastes #478643 Raw Edit

Unnamed

public php v1 · immutable
·published 2007-05-09 09:05 UTC
rendered paste body
//---		// relative_date() takes a UNIX timestamp and will create a relative 		// if no relative date can be made, return a International standard date instead		// @param int $stamp		//---		private function relative_date( $stamp ) {			# A minute contains 60 seconds.			# An hour contains 3600 seconds.			# A day contains 86400 seconds.			# A week contains 604800 seconds.			# Default Relative cutoff is 1209600						#Zula::debug_print( $stamp );								$time_diff = time() - $stamp;						if ( $time_diff >= $this->relative_cut_off ) {				// Return a normal formated date as the cutoff point has been reached				return $this->make( self::_STANDARD_DATE, $stamp, false );			} else if ( $time_diff < 0 ) {				// Time differene is negative ... means it's from the future! cool! ... um, yes.									if ( $time_diff <= -1209600 ) {	  							// Output in Weeks					return 'Within '.intval( $time_diff / -604800 ).' Weeks';							} else if ( $time_diff <= -604800 ) {								// Output 1 Week Ago					return 'Within 1 Week';								} else if ( $time_diff <= -172800 ) {	  							// Output in Days					return 'Within '.intval( $time_diff / -86400 ).' Days';	  							} else if ( $time_diff <= -86400 ) {	  							// Output 1 Day Ago	  						return 'Within 1 Day';				} else if ( $time_diff <= -7200 ) {			  								// Output in Hours					return 'Within '.intval( $time_diff / -3600 ).' Hours';				  				} else if ( $time_diff <= -3600 ) {								// Output 1 Hour Ago					return 'Within 1 Hour';				 				} else if ( $time_diff <= -120 ) {	  							// Output in Mins					return 'Within '.intval( $time_diff / -60 ).' Minutes';	  							} else if ( $time_diff <= -60 ) {					// Output 1 Minute Ago					return 'Within 1 Minute';	  							} else if ( $time_diff <= -60 ) {					// Output 1 Minute Ago					return 'Within 1 Minute';	  							} else if ( $time_diff < -1 ) {	  							// Output in Seconds					return 'Within '.intval( $time_diff ).' Seconds';	  							} else if ( $time_diff == -1 ) {	  							// Output 1 Second Ago					return 'Within 1 Second';	  					} 						} else {								if ( $time_diff >= 1209600 ) {	  							// Output in Weeks					return intval( $time_diff / 604800 ).' Weeks Ago';							} else if ( $time_diff >= 604800 ) {								// Output 1 Week Ago					return '1 Week Ago';								} else if ( $time_diff >= 172800 ) {	  							// Output in Days					return intval( $time_diff / 86400 ).' Days Ago';	  							} else if ( $time_diff >= 86400 ) {	  							// Output 1 Day Ago	  						return '1 Day Ago';				} else if ( $time_diff >= 7200 ) {			  								// Output in Hours					return intval( $time_diff / 3600 ).' Hours Ago';				  				} else if ( $time_diff >= 3600 ) {								// Output 1 Hour Ago					return '1 Hour Ago';				 				} else if ( $time_diff >= 120 ) {	  							// Output in Mins					return intval( $time_diff / 60 ).' Minutes Ago';	  							} else if ( $time_diff >= 60 ) {					// Output 1 Minute Ago					return '1 Minute Ago';	  							} else if ( $time_diff > 1 ) {	  							// Output in Seconds					return intval( $time_diff ).' Seconds Ago';	  							} else if ( $time_diff < 1 ) {	  							// Output 1 Second Ago					return '1 Second Ago';	  					}							}			}