Server Time Difference

  Previous article Next article  

Server Time Difference

  Article optimized for CMSMS 2.x

  Author:
  Last tested in: CMSMS 2.2.2
  Last updated: 22-07-2016
  Comments: 0

Having problems with start and end time settings in a CMS Made Simple™ module? A news article is published, but isn't visible at the frontend of the website... You could have problems with the time settings at your website and/or server.

A few useful checks to see if it is a problem you can fix yourself, or you have to contact your webhost...

  How to use

 1. UNIX timestamp

First check the current Unix timestamp by adding in a page:

{$smarty.now|date_format:'%A %d-%m-%Y %T %Z'}

The output at the moment you opened this page is:
Friday 18-08-2017 05:03:12 CEST



 2. Check the time zone settings (daylight saving time)

You can test this with a User Defined Tag (UDT).
In the Admin panel go to Extensions >> User Defined Tags and create a new UDT:

UDT: test_server_timezones
$db = \CmsApp::get_instance()->GetDb();
echo "PHP time is " . $db->DbTimeStamp(time()) . "<br />";
echo "MySQL time is '" . $db->GetOne('SELECT NOW()') . "'<br />";

To use this test UDT click on the "Run" button in the Admin page. The output will be shown in a pop-up box.

The generated output for this (Dutch) webserver is:
PHP time is '2017-08-18 05:03:12'
MySQL time is '2017-08-18 05:03:12'

Is the date and time not correct? Adjust the settings in your config.php file in the CMSMS™ website root.
Change the value for your countries time zone (or the time zone where your server is...).

$config['timezone'] = 'Europe/Amsterdam';

Is your database server on a different machine, it may be necessary to also add:

$config['set_db_timezone'] = 'Europe/Amsterdam';


You still have a time difference issue, there can be a problem at your server. We can test it with two small UDT's.

 3. Database Time Difference

Related CMS Made Simple warning:

Testing for time difference in the database (test_db_timedifference)
Detected a difference of at least ... seconds. This may effect the system dramatically.

In the Admin panel go to Extensions >> User Defined Tags and create a new UDT:

UDT: test_db_timedifference
$db = \CmsApp::get_instance()->GetDb();
$diff = time() - $db->GetOne('SELECT UNIX_TIMESTAMP()');
echo "DB Time Difference is $diff seconds";

This UDT tests the time difference between the current Unix timestamp and database server time.

The generated output for this (Dutch) webserver is:
DB Time Difference is 0 seconds

To use the test UDT click on the "Run" button in the Admin page. The output will be shown in a pop-up box.
The output should be 0 seconds, in case of another value you need to contact your web host to change the server settings.


A2 Webhosting CMS Made Simple

 4. File System Time Difference

Related CMS Made Simple warning:

Testing for time difference in the file system (test_file_timedifference)
A discrepency in time with the PHP environment was detected. This may cause problems when publishing i.e. news articles.

In the Admin panel go to Extensions >> User Defined Tags and create a new UDT:

UDT: test_file_timedifference
$fn = TMP_CACHE_LOCATION.'/test.file';
touch($fn);
$diff = time() - filemtime($fn);
echo "File Time Difference is $diff seconds";

This UDT tests the time difference between the current Unix timestamp and file server time.

The generated output for this (Dutch) webserver is:
File Time Difference is 0 seconds

To use the test UDT click on the "Run" button in the Admin page. The output will be shown in a pop-up box.
The output should be 0 seconds, in case of another value you need to contact your web host to change the server settings.


A2 Webhosting CMS Made Simple

  Comments

  Click here to leave a comment






This is a captcha-picture. It is used to prevent mass-access by robots. (see: www.captcha.net)
  « Enter the CAPTCHA code (lower case)

Your IP address will be stored on submit. I reserve the right to change or delete your response without notice!
In case of abuse your IP address will be blocked!


Can I have your attention for a moment?

Did this tutorial help you solving a problem at your (clients) website and it saved you many hours of work? Great!!
Consider buying Rolf a cup of coffee in return! [ Click here ]


  0 Comments

No comments yet...

CMS Made Simple 2.2.2 - Tutorials, tips and tricks - CMSMS 2.2.2

Server Time Difference

  Article optimized for CMSMS 2.x

  Author:
  Last tested in: CMSMS 2.2.2
  Last updated: 22-07-2016
  Comments: 0

A2 Webhosting CMS Made Simple