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

I want to set it according to India (+0530), but there is no option to change the timezone....it showing +0000. in timezone.

Q2A version: Latest Version 1.85

3 Answers

+1 vote
by
selected by
 
Best answer

The "when" HTML fragment is created by the following code snippet from the function qa_post_html_fields() in qa-include/app/format.php:

if (isset($post['created']) && @$options['whenview']) {
  $fields['when'] = qa_when_to_html($post['created'], @$options['fulldatedays']);

  if ($microdata) {
    $gmdate = gmdate('Y-m-d\TH:i:sO', $post['created']);
    $fields['when']['data'] = '<time itemprop="dateCreated" datetime="' . $gmdate . '" title="' . $gmdate . '">' . $fields['when']['data'] . '</time>';
  }   
}

You can change the value either by overriding the function qa_post_html_fields() so that it returns a modified value for $fields['when'], or (in your theme) by overriding the method post_meta_when() so that it renders the exact HTML you need.

Assuming that PHP and the database on your system are configured with the same timezone you could do the following to get the timestamp with the proper timezone:

$tz = date_default_timezone_get();
$dt = new DateTime(strftime("%F %T", $post['raw']['created']), new DateTimeZone($tz));
echo $dt->format('Y-m-d H:i:s P');

If PHP and database are configured with different timezones you need to convert the timestamp from the database timezone to the PHP timezone first:

$db_tz  = 'UTC';
$php_tz = date_default_timezone_get();
$dt = new DateTime(strftime("%F %T", $post['raw']['created']), new DateTimeZone($db_tz));
$dt->setTimezone(new DateTimeZone($php_tz));
echo $dt->format('Y-m-d H:i:s P');

by
Tell me a single code to add there and test the results..., Same theme (this) is used by me.
0 votes
by
Q2A (this website) is set timezone 000 (UK) by admins. You (users) cannot change it.
by
i know i cant change this website timestamp.... but my question is for my website.... why could you not understood.
0 votes
by

if you have access to php.ini You can set the schedule from there

date.timezone = "US/Central"

...