Jump to content

[SOLVED] Date display using Today & Yesterday


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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.