Page 1 of 2
HESK Time
Posted: Tue Apr 15, 2014 10:48 pm
by bastiaan.c
Script URL:
Version of script: 2.5.3
Hosting company:
URL of phpinfo.php:
URL of session_test.php:
What terms did you try when SEARCHING for a solution:
Write your message below:
Hi,
I have some difficulties with the time that is displayed in HESK. I have added a video on YouTube, so I can show a bit better what I mean:
Basically:
- My Ticket history time does not match with the updated time on top of the ticket

Please help

I tried everything. Thanks for all you do.
http://youtu.be/JeSnH5x3ycU
Re: HESK Time
Posted: Wed Apr 16, 2014 1:14 pm
by Klemen
This is probably happening because MySQL and PHP on the server are using different time zones.
What result do you get if you save this code in file "test.php", upload to your main HESK folder and open in browser?
Code: Select all
<?php
define('IN_SCRIPT',1);
define('HESK_PATH','./');
require(HESK_PATH . 'hesk_settings.inc.php');
require(HESK_PATH . 'inc/common.inc.php');
hesk_load_database_functions();
hesk_dbConnect();
$db_time = hesk_dbTime();
$php_time = time();
$difference = ($db_time - $php_time) / 3600;
echo "MySQL time: $db_time<br />PHP time: $php_time<br />Difference: $difference hours";
Re: HESK Time
Posted: Wed Apr 16, 2014 7:13 pm
by bastiaan.c
Hi Klemen,
It says:
MySQL time: 1397682753
PHP time: 1397675553
Difference: 2 hours
Re: HESK Time
Posted: Thu Apr 17, 2014 9:36 am
by Klemen
Yes, your PHP and MySQL are set to different time zones hence the difference.
Does uploading these files to your help desk fix the issue?
http://www.hesk.com/extras/hesk253_mysql_time.zip
(note that existing "History" elements will not be modified, but should work good for any new changes).
Re: HESK Time
Posted: Thu Apr 17, 2014 10:51 am
by bastiaan.c
Hi Klemen, could you please sent me the code that I should change?
All my files have modification and I am afraid that it would cause different issues

Sorry for that

Re: HESK Time
Posted: Thu Apr 17, 2014 3:54 pm
by Klemen
In inc/common.inc.php change hesk_date function to
Code: Select all
function hesk_date($dt='', $from_database=false)
{
global $hesk_settings;
if (!$dt)
{
$dt = time();
}
else
{
$dt = strtotime($dt);
}
// Adjust MySQL time if different that PHP time
if ($from_database)
{
if ( ! defined('MYSQL_TIME_DIFF') )
{
define('MYSQL_TIME_DIFF', time()-hesk_dbTime() );
}
if (MYSQL_TIME_DIFF != 0)
{
$dt += MYSQL_TIME_DIFF;
}
}
// Add HESK set time difference
$dt += 3600*$hesk_settings['diff_hours'] + 60*$hesk_settings['diff_minutes'];
// Daylight saving?
if ($hesk_settings['daylight'] && date('I', $dt))
{
$dt += 3600;
}
// Return formatted date
return date($hesk_settings['timeformat'], $dt);
} // End hesk_date()
DIFF for other two files:
Code: Select all
Index: admin/admin_ticket.php
===================================================================
--- admin/admin_ticket.php (revision 246)
+++ admin/admin_ticket.php (working copy)
@@ -261,8 +261,8 @@
'lastreplier' => $ticket['lastreplier'],
'subject' => $ticket['subject'],
'message' => stripslashes($msg),
- 'dt' => hesk_date($ticket['dt']),
- 'lastchange' => hesk_date($ticket['lastchange']),
+ 'dt' => hesk_date($ticket['dt'], true),
+ 'lastchange' => hesk_date($ticket['lastchange'], true),
);
// 2. Add custom fields to the array
@@ -472,7 +472,7 @@
<tr>
<td>'.$hesklang['created_on'].': </td>
- <td>'.hesk_date($ticket['dt']).'</td>
+ <td>'.hesk_date($ticket['dt'], true).'</td>
<td> </td>
</tr>
@@ -546,7 +546,7 @@
<tr>
<td>'.$hesklang['last_update'].': </td>
- <td>'.hesk_date($ticket['lastchange']).'</td>
+ <td>'.hesk_date($ticket['lastchange'], true).'</td>
<td> </td>
</tr>
@@ -780,7 +780,7 @@
<td>
<table border="0" width="100%" cellspacing="0" cellpadding="3">
<tr>
- <td class="notes"><i><?php echo $hesklang['noteby']; ?> <b><?php echo ($note['name'] ? $note['name'] : $hesklang['e_udel']); ?></b></i> - <?php echo hesk_date($note['dt']); ?><br /><img src="../img/blank.gif" border="0" width="5" height="5" alt="" /><br />
+ <td class="notes"><i><?php echo $hesklang['noteby']; ?> <b><?php echo ($note['name'] ? $note['name'] : $hesklang['e_udel']); ?></b></i> - <?php echo hesk_date($note['dt'], true); ?><br /><img src="../img/blank.gif" border="0" width="5" height="5" alt="" /><br />
<?php echo $note['message']; ?></td>
</tr>
</table>
@@ -863,7 +863,7 @@
<table border="0" cellspacing="1">
<tr>
<td><?php echo $hesklang['date']; ?>:</td>
- <td><?php echo hesk_date($ticket['dt']); ?></td>
+ <td><?php echo hesk_date($ticket['dt'], true); ?></td>
</tr>
<tr>
<td><?php echo $hesklang['name']; ?>:</td>
@@ -1233,7 +1233,7 @@
if ($i) {$color = 'class="ticketrow"'; $i=0;}
else {$color = 'class="ticketalt"'; $i=1;}
- $reply['dt'] = hesk_date($reply['dt']);
+ $reply['dt'] = hesk_date($reply['dt'], true);
?>
<tr>
<td <?php echo $color; ?>>
Index: ticket.php
===================================================================
--- ticket.php (revision 246)
+++ ticket.php (working copy)
@@ -305,11 +305,11 @@
</tr>
<tr>
<td>'.$hesklang['created_on'].': </td>
- <td>'.hesk_date($ticket['dt']).'</td>
+ <td>'.hesk_date($ticket['dt'], true).'</td>
</tr>
<tr>
<td>'.$hesklang['last_update'].': </td>
- <td>'.hesk_date($ticket['lastchange']).'</td>
+ <td>'.hesk_date($ticket['lastchange'], true).'</td>
</tr>
<tr>
<td>'.$hesklang['last_replier'].': </td>
@@ -402,7 +402,7 @@
<table border="0" cellspacing="1">
<tr>
<td class="tickettd"><?php echo $hesklang['date']; ?>:</td>
- <td class="tickettd"><?php echo hesk_date($ticket['dt']); ?></td>
+ <td class="tickettd"><?php echo hesk_date($ticket['dt'], true); ?></td>
</tr>
<tr>
<td class="tickettd"><?php echo $hesklang['name']; ?>:</td>
@@ -754,7 +754,7 @@
$unread_replies[] = $reply['id'];
}
- $reply['dt'] = hesk_date($reply['dt']);
+ $reply['dt'] = hesk_date($reply['dt'], true);
?>
<tr>
<td <?php echo $color; ?>>
Re: HESK Time
Posted: Thu Apr 17, 2014 4:47 pm
by bastiaan.c
Re: HESK Time
Posted: Fri Apr 18, 2014 9:54 am
by bastiaan.c
Hi Klemen it must have been a cache thing or I did not see it because I checked a ticket without a note????
But, If I go to the ticket list and click on a ticket in the notes it now says :
-------------------------------------------------------------------------------------------
Note by First Name Last Name - 13-Apr-2014 14:05:19
esk_date($note['dt']); ?>
-------------------------------------------------------------------------------------------
Every note shows this "esk_date($note['dt']); ?>"
I am sorry but I hope the esk_date($note['dt']); ?> can go away?
Re: HESK Time
Posted: Fri Apr 18, 2014 1:09 pm
by bastiaan.c
I found out that it might be this:
<td class="notes"><i><?php echo $hesklang['noteby']; ?> <b><?php echo ($note['name'] ? $note['name'] : $hesklang['e_udel']); ?></b></i> - <?php echo hesk_date($note['dt'], true); ?><br /><img src="../img/blank.gif" border="0" width="5" height="5" alt="" /><br />
<?php echo $note['message']; ?></td>
It now says �� �� �
Re: HESK Time
Posted: Fri Apr 18, 2014 1:26 pm
by bastiaan.c
I have fixed it by not changing this part:
Code: Select all
- 'dt' => hesk_date($ticket['dt']),
- 'lastchange' => hesk_date($ticket['lastchange']),
+ 'dt' => hesk_date($ticket['dt'], true),
+ 'lastchange' => hesk_date($ticket['lastchange'], true),
);
[code]
Is that correct?
Thanks
Re: HESK Time
Posted: Sat Apr 19, 2014 8:58 am
by Klemen
Works fine in my help desk, you probably made a typo somewhere? "esk_date" is no function, it should be "hesk_date" and the PHP tag is probably missing as well?
Re: HESK Time
Posted: Fri May 30, 2014 1:49 pm
by Aakash
Hi klemen
I also have problem regarding time & i tried your this code but it not work's for me
i am from india & i want to set time in Indian IST +5:30
Re: HESK Time
Posted: Sat May 31, 2014 7:54 am
by Klemen
A few things regarding time differences have been fixed for the next HESK version.
You can expect 2.5.4 in second part of June and it will address some time-related issues.
Re: HESK Time
Posted: Tue Mar 24, 2015 9:58 pm
by bastiaan.c
Hi Klemen,
I have updated HESK to 2.6.2 and now the notes are 1 hour later (too late) then the rest of the system. Can you please advise?
The notes should be minus 1 hour
Thanks so much and sorry that I have this issue again

Re: HESK Time
Posted: Wed Mar 25, 2015 1:20 pm
by Klemen
I can't seem to duplicate this issue on my server, the same function is used for processing notes date/time and ticket/replies date/time.
Does anything change if you turn "Daylight saving" to on or off in settings (Misc tab)?