# Today, yesterday function()

**URL:** <https://forum.kirupa.com/t/today-yesterday-function/41543>\
**Category:** Uncategorized\
**Created:** [January 30, 2004, 9:33am UTC](https://forum.kirupa.com/t/today-yesterday-function/41543 "2004-01-30T09:33:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![OKtrust](https://avatars.discourse-cdn.com/v4/letter/o/c77e96/32.png) [@OKtrust](https://forum.kirupa.com/u/OKtrust)\
**Post date:** [January 30, 2004, 9:33am UTC](https://forum.kirupa.com/t/today-yesterday-function/41543/1 "2004-01-30T09:33:55Z")

</div>

this is “virgin” source:

```php

function form_date($time, $verbose = 1)
{
	global $config;
	
	if( $time < (60 * 60 * 24) )
	{
		return "N/A";
	}

	$time += $config['timeoffset'] * 3600;
	
	if( date("d.m.Y", (time() + $config['timeoffset'] * 3600) ) == date('d.m.Y', $time) && $verbose )
	{
		return "<b>today</b>, " . date("H:i", $time);
	} else {
		return date("d.m.Y, H:i", $time);
	}
}

```

it wil print “today” if user see the post in the same day.  
and here is my addition after if condition:

```php

}
	
	else if( date("d.m.Y", (time() + $config['timeoffset'] * 3600) ) > date('d.m.Y') && $verbose )
	{
	return "<b>yesterday</b>, " . date("H:i", $time);
	} else if( date("d.m.Y", (time() + $config['timeoffset'] * 3600) ) > date('d.m.Y') && $verbose )
	{
	return "<b>the day before yesterday</b>, " . date("H:i", $time);

```

but it doesnt work like my mind :((, it print “today” correct, but it always print “yesterday” althought the time is the day before yesterday or older, please help me !
