MENU

Server Time Difference

  Previous article Next article  

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'}


 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.

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'] = 'true';


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.

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.

 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.

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.


Buy Me A Coffee


  Comment Form

ReviewManager

Click here to open the form

ReviewManager

  3 Comments

Buy Me A Coffee

CMS Made Simple - Tutorials, Tips and Tricks - CMSMS

Server Time Difference

  Article optimized for CMSMS 2.x

  Author:
  Last tested in: CMSMS 2.2.19
  Last updated: 07-04-2020
  Comments: 3
  http://cms.ms/hZ0z


Buy Me A Coffee




Advertisement


Ads help me to help you! Thanks!

Ads help me to help you! Buy products from these advertisers!