You are here

function privatemsg_format_date in Privatemsg 7

Same name and namespace in other branches
  1. 7.2 privatemsg.module \privatemsg_format_date()

Formats a timestamp according to the defines rules.

Examples/Rules:

Current hour: 25 min ago Current day (but not within the hour): 10:30 am Current year (but not on the same day): Nov 25 Prior years (not the current year): 11/25/08

Parameters

$timestamp: UNIX Timestamp.

Return value

The formatted date.

3 calls to privatemsg_format_date()
template_preprocess_privatemsg_view in ./privatemsg.module
theme_privatemsg_list_field__last_updated in ./privatemsg.theme.inc
Theme the last updated column.
theme_privatemsg_list_field__thread_started in ./privatemsg.theme.inc
Theme the thread started column.

File

./privatemsg.module, line 3195
Allows users to send private messages to other users.

Code

function privatemsg_format_date($timestamp) {
  if ($timestamp > (int) (REQUEST_TIME / 3600) * 3600) {
    return t('@interval ago', array(
      '@interval' => format_interval(abs(REQUEST_TIME - $timestamp), 1),
    ));
  }
  if ($timestamp > (int) (REQUEST_TIME / 86400) * 86400) {
    return format_date($timestamp, 'privatemsg_current_day');
  }
  if ($timestamp > mktime(0, 0, 0, 1, 0, date('Y'))) {
    return format_date($timestamp, 'privatemsg_current_year');
  }
  return format_date($timestamp, 'privatemsg_years');
}