Timezone madness with WordPress

date.timezone is not working

  • The date.timezone from my htaccess is not working.
  • I’ve set the date.timezone in my php.ini but it’s not working

On my server configuration we set the global php.ini timezone but it wasn’t working on my WordPress plugin.

I had changed the admin Settings to the correct timezone but still, it was using UTC. I’ve tried overriting the date.timezone using the .htaccess and the wp-config.php without any luck.

current_time() to the rescue

This beautiful core function will solve all your headaches: http://codex.wordpress.org/Function_Reference/current_time

How does it work?

You should use this function instead of date() or time() in your themes or plugins.

Why?

It will take into consideration the timezone set from the admin Settings page.

How do I use it?

No comments yet, leave yours!

Leave a Reply

Add <code> Some Code </code> by using this tags.