Changing current date on WordPress Header.php

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?

Read More

enter image description here

enter image description here

Related posts

Leave a Reply

4 comments

  1. The 1 in current_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 to 0 instead of 1 will return the local Australian time you set in the General Settings.

    So the code would look like:

    <div class="current-date">
      <div>
      <?php echo date( 'D, ' . get_option('date_format'), current_time( 'timestamp', 0 ) ); ?>
      </div>
    </div>
    
  2. get_option('date_format')
    

    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:

    <div class="current-date">
     <div>
     <?php echo date( 'D, ' . get_option('date_format'), strtotime('+5 hour') ); ?>
     </div>