function token_get_date_token_values in Token 6
Same name and namespace in other branches
- 5 token.module \token_get_date_token_values()
Build a list of common date tokens for use in hook_token_values().
4 calls to token_get_date_token_values()
- comment_token_values in ./
token_comment.inc - Implements hook_token_values() on behalf of comment.module.
- node_token_values in ./
token_node.inc - Implements hook_token_values() on behalf of node.module.
- token_token_values in ./
token.module - Implements hook_token_values().
- user_token_values in ./
token_user.inc - Implementation of hook_token_values().
File
- ./
token.module, line 517 - The Token API module.
Code
function token_get_date_token_values($timestamp = NULL, $token_prefix = '', $langcode = NULL) {
static $formats;
if (!isset($formats)) {
$formats = array();
$formats['small'] = variable_get('date_format_short', 'm/d/Y - H:i');
$formats['yyyy'] = 'Y';
$formats['yy'] = 'y';
$formats['month'] = 'F';
$formats['mon'] = 'M';
$formats['mm'] = 'm';
$formats['m'] = 'n';
$formats['ww'] = 'W';
if (version_compare(PHP_VERSION, '5.1.0', '>=')) {
$formats['date'] = 'N';
}
$formats['day'] = 'l';
$formats['ddd'] = 'D';
$formats['dd'] = 'd';
$formats['d'] = 'j';
}
$time = time();
if (!isset($timestamp)) {
$timestamp = $time;
}
$tokens = array();
foreach ($formats as $token => $format) {
$tokens[$token_prefix . $token] = token_format_date($timestamp, 'custom', $format, NULL, $langcode);
}
$tokens[$token_prefix . 'raw'] = $timestamp;
$tokens[$token_prefix . 'since'] = format_interval($time - $timestamp, 2, $langcode);
return $tokens;
}