Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
464 views
in Q2A Core by

How can I add time to the end of the date in questions and answers and comments?

Q2A version: 1.8

1 Answer

+2 votes
by
selected by
 
Best answer

Overriding the method post_meta_when() in your theme (file qa-theme.php) with custom time formatting should do what you want. I'm using something similar to this in my own theme:

function post_meta_when($post, $class) {
  if (array_key_exists('otime', $post['raw']) and $post['raw']['_type'] !== 'Q') {
    $this->_format_timestamp($post['raw']['otime'], $class);
  } else {
    $this->_format_timestamp($post['raw']['created'], $class);
  }
}

private function _format_timestamp($timestamp, $class) {
  $interval     = qa_opt('db_time') - $timestamp;
  $fulldatedays = qa_opt('show_full_date_days');

  if ($interval < 0 || (isset($fulldatedays) && $interval > 86400 * $fulldatedays)) {
    $gmdate = gmdate('Y-m-d H:i:s e', $timestamp);
    $post_when = array(
      'data' => '<time itemprop="dateCreated" datetime="' . $gmdate . '" title="' . $gmdate . '">' . $gmdate . '</time>',
    );
  } else {
    // ago-style date
    $post_when = qa_lang_html_sub_split('main/x_ago', qa_html(qa_time_to_string($interval)));
  }

  $this->output_split($post_when, $class . '-when');
}

by
thank u so much
...