Jump to content

Using the date function to print 'today at x time' - Please help!!


skard

Recommended Posts

Hi. I'm not a programmer, so i hope it doesnt seem rude my asking for help here. Is it allowed? I run a site built in php and often can't get hold of a programmer so try and change little bits myself, usually by finding other bits of code around my site that do a similiar job, and then copying and modifying them.

Something i've been trying to do, but I'm completely lost with it, is this:

 

I have a forum, and on the latest posts page it looks something like this -

 

Last Post:

14th February 2008 16:02

by John Doe

 

Now the code that prints the date part (14th Febuary 2008 16:02) is the following:

 

$content .= $tmp->LastPost->DateFormatted;

 

I'm trying to get it to not just print the date, but if the post was made yesterday, then print:

 

Last Post:

Yesterday at 16:02

by John Doe

 

or if it was made today, then:

 

Last Post:

Today at 16:02

by John Doe

 

A friend of mine changed it to this: $content .= ((mktime() - $tmp->LastPost->Date < 86400) ? 'Today' : $tmp->LastPost->DateFormatted);

Which works to some degree as the final output is this: Last Post: Today by John Doe

but it doesnt show the time the post was made, and its not actually 'today' but in the last 24 hours, which isnt what i want.

 

Can anyone help? Much appreciated if someone can  :) Thanks in advance for any help

 

 

 

 

 

 

 

 

 

 

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.