Jump to content

[SOLVED] Date display using Today & Yesterday


lxndr

Recommended Posts

Was just wondering if there's an easy way of being able to display a unix timestamp for GMT so that if the date in question is today or yesterday the date gets displayed using those terms while all other dates get shown as actual dates.  As an example, that would mean I'd get something like:

 

      user        joined

  Person A  Today, 02:52 AM

  Person B  Yesterday, 06:59 PM

  Person C  25 Jan 2008, 04:45 PM

  Person D  24 Jan 2008, 11:02 AM

  Person E  24 Jan 2008, 09:34 AM

 

 

TIA for any help or advice.

 

I'm thinking something as simple as:

if (date('m/d/y', $timestamp) = date('m/d/y', strtotime('-1 day'))
{
$listed_day = 'Yesterday'
}
else
{
$listed_day = date('m/d/y')
}

 

I used a different format, now that I look at your original post again, but the concept remains.  strtotime() should solve your problem.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.