English (United Kingdom)
Knowledge Base  >  Vik Rent Car  >  Dates, Times & Calendars  >  Time is shifted by a few hours

If the time displayed in the front-end or in the back-end of your website is not reflecting your Local Time, then the problem is caused by a Timezone difference.
For example, if you have just received a booking and the time displayed is one or a few hours ahead or back your current Local Time, the Timezone of your Server is different than your Local Time.

From the WordPress Administrator Settings Page you can choose your local Timezone and the system will attempt to force the Server to use that Timezone. However, most of the times this operation will not fix the Timezone issue of your website because of some Server restrictions.

If changing the Timezone from the Settings Page will not solve the problem then it is necessary to override it in a different way. This is because some PHP functions used by the extension to format Dates or generate Unix timestamps, take the time directly from the server so overriding the Timezone via PHP will not help.

There are two ways for overriding the Server default Timezone:

  1. Set it from the .htaccess file in the root folder of your website. This solution works only for those web servers running Apache.
  2. Change the default Timezone directly from the PHP.INI configuration file of your Server. Usually, only your Hosting Company is able to access and modify the PHP Configuration, especially if your space is a Virtual Host.

By opening the file .htaccess, which is located in the root folder of your website, with a good text editor, you should place the code below within a specific section of the file:

## Begin - Custom redirects
#
# If you need to redirect some pages, or set a canonical non-www to
# www redirect (or vice versa), place that code here. Ensure those
# redirects use the correct RewriteRule syntax and the [R=301,L] flags.
#
SetEnv TZ Europe/Rome
## End - Custom redirects

By placing the instruction SetEnv TZ Europe/Rome in that specific part of the file .htaccess, we ensure to not be causing problems to the other Apache Rules.

The instruction SetEnv TZ Europe/Rome will force the Timezone of the server to Rome time. The correct syntax is "SetEnv TZ Location" where SetEnv TZ is a special directive of Apache to define the Timezone and Location is the actual location of the Timezone you want to use.

You can find a complete list of supported Timezone at the URL below:
http://www.php.net/manual/en/timezones.php

By saving the modified file .htaccess and by re-uploading it onto your server, the time of the bookings should reflect your Local time.

If this modification will not affect anything then you should contact your Hosting Company so that they can change the Server Timezone directly from the PHP.INI Configuration file.

Last Update: 2019-11-26
Helpful?
This site uses cookies. By continuing to browse you accept their use. Further information