Jump to content

Recommended Posts

Posted
	public static function roundedDiffFromSeconds( $seconds, $memberOrLanguage=NULL )
	{
		$now 	= static::ts( time() );
		$then	= static::ts( time() - $seconds );
		return $now->roundedDiff( $then, $memberOrLanguage );
	}

Don't panic! This is not related to all the other DateTime shenanigans going on. Just a small bug with a big return - routinely 52 years.

The problem is having $then calculated as time() - $seconds. That needs to just be seconds:

$then = static::ts($seconds);

You only use this in one spot (admin\stats\timeToSolved.phtml) that I can see so probably just been overlooked for a while.

Full Explained working on something not quite two minutes old:

$now: 1663390800
$then:  1663390800 - 1663390700 = 100
$now->roundedDiff ($then);

roundedDiff then immediately calculates its own difference:

$this->diff($date) which in this case is $this->diff(100) which is the difference between right now and 100 seconds after January 1, 1970 midnight UTC.
 

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...