How do I change the date format and print Today

Hi all

I’m working with some event listings which all have dates printed below.
What I’d like to do is show today and tomorrow in place of the date format.

Example:

21 March - Would print Today
22 March - Would print Tomorrow
23 March - Would stay the same etc

I’m currently using basic date.

date("l j")

Does anybody know how to do this?
Any guidance on what sort of logic I need to use.

Thanks,
Barry

rough psuedo code

If system_date == stored_date
$diplay_date = “Today”
else if system_date + 1 day == stored_date
$display_date = “Tomorrow”
else
$display_date = stored_date
endif
echo $display_date

Thanks litebearer

The output I already have is being derived from a Drupal array, as shown below.
Finding it hard how I could modify this, code it up.

array
    (
      'data' => $sorted[date("l j", strtotime($node->field_event_date_and_time[LANGUAGE_NONE][0]['value']))][] = l($node->title,drupal_get_path_alias('node/'.$node->nid)),
      'class' => array('some_class'),
    );

I did try adding the below just above the array which printed today 5 times above all my markup.

if (strtotime($node->field_event_date_and_time[LANGUAGE_NONE][0]['value']) > strtotime('now')) {
        print "today";
    }

Any suggestions, thanks.

Barry

Looking at litebearer snippet, I need to create a function that I can use that will check the date.

Can anybody help coding this up?

I’ve made a rough start on a function:

function datecheck() {
  if (date('now')) {
    print "today";
  } else if (date("+1 day")) {
    print "tommorrow";
  } else if (date("-1 day")) {
    print "yesterday";
  } else {
    print "date as normal";
  }
}

I’d then like to simply wrap the function around the code above.
We can also ignore the post/code above for now if thats confusing things.

Thanks, Barry

Other something like:

function datecheck() {

  $datetoday = date('now');

  if ($datetoday == date('now')) {
    print "today";
  } else if ($datetoday == date("+1 day")) {
    print "tommorrow";
  } else if ($datetoday == date("-1 day")) {
    print "yesterday";
  } else {
    print $datetoday;
  }
}

?

Thanks