My site uses a WordPress theme. The theme shows default US date on the header. I would like to change this to Australian time zone. The code that shows US date is below:
<div class="current-date">
<div>
<?php echo date( 'D, ' . get_option('date_format'), current_time( 'timestamp', 1 ) ); ?>
</div>
</div>
How do I change this to Australian time zone date?
The
1
incurrent_time( 'timestamp', 1 )
is telling WordPress to show the current time in the GMT time zone, instead of the custom time zone that you set. This is why it’s not changing when you change the time zone in the admin area.Changing the second parameter
$gmt
to0
instead of1
will return the local Australian time you set in the General Settings.So the code would look like:
This code implies that in your wordpress administration panel there should be an option for date format. Please check the admin page that includes settings such as the site name and timezone.
if you are convinced you want to change the hard-code of word-press, replace with the following:
The code
get_option('date_format')
takes the format date in your WP Administration Panel.You must be confused between “date format” and “timezone”
You can define your date format in the settings general screen (http://codex.wordpress.org/Settings_General_Screen). (Search “Date Format” in the page).
http://codex.wordpress.org/Settings_General_Screen
You can go to Dashboard on the top left corner, then go to settings in the right hand side of the page, then go to general and you can change the time zone there
http://codex.wordpress.org/Settings_General_Screen