# WordPress Problem: PHP mktime() Not Working/Broken – Wrong Timezone Published: 2010-09-26 Updated: 2010-10-10 Author: Alexander Conroy Categories: Wordpress Description: Trying to figure out why mktime() shows the wrong time/date in wordpress? Has to do with locale and the Loop. This posts shows the proper function to use. --- ![](/wp-content/uploads/2010/09/imgres.png)Quick note for WordPress developers, this one had me scratching my head. If you use mktime() in your plugin code you will notice the timezone will always reflect GMT. There is a reason for this. Notice that in settings, WordPress asks you for your locale. It then tells you what the time is in GMT and then what the new locale time is. Somehow, WordPress overrides php.ini, system time, etc and thinks its GMT when using mktime(). You cant change it anywhere, not in .htaccess ,nothing. It’s probably embedded deep within the core of wordpress somewhere, and has something to do with plugin functions called within [the Loop](http://codex.wordpress.org/The_Loop). Anyways, how do we get the current linux timestamp that mktime() normally so easily creates for us? Use the following wordpress function: [current_time(“timestamp”)](http://codex.wordpress.org/Function_Reference/current_time); This will give you your standard linux timestamp. It also has the ability to create a mysql timestamp using the format: [current_time(“mysql”)](http://codex.wordpress.org/Function_Reference/current_time); Test it out, but don’t try using a separate .php to test as mktime() works fine outside of the Loop. Hope this helps!! --- [Back to Index](/llms.txt)