My local WordPress installation on XAMPP seems to have a wrong time setting. When I do

date( 'Y-m-d H:i:s' );

I get 2017-02-21 10:46:43 as result. However my PCs time really is 2017-02-21 11:46:43, so my WordPress is one hour behind.

Now I already did, what was recommended here and changed date.timezone in the php.ini to my timezone and restarted the apache afterwards, since I thought the problem might be cause by XAMPP. But still I get the wrong time displayed.

I also went to settings -> general in WordPress and changed the timezone there to the correct one. The local time shown there is correct:

"Local time is 2017-02-21 11:46:43"

But when I use the function, it's still wrong. Do you have any idea, what else could cause this problem?

  • How is it in any way related to wordpress (except for the most none important one that you run wordpress on the same server)? – Mark Kaplun Feb 21 '17 at 11:36

date() is a PHP function depending on your server settings. You can go around that by using the WordPress function:

current_time( 'Y-m-d H:i:s' );

This function takes the settings in wp-admin into account.


use wordpress functions to get time according to WordPress settings and time zone such as the_time and the_date

 the_date('F j, Y');
 the_time('g:i a');
  • Nope - the_date() and related show the publication date of the current post, not the current time. – squarecandy Sep 12 '18 at 1:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.