Calculation difference between date is not correct

Ask your questions here.
Post Reply
tolu77
Posts: 9
Joined: 03 Oct 2023, 19:59
Name: Thomas Ludwig
Location: Deutschland

Calculation difference between date is not correct

Post by tolu77 »

Hello everyone, I have the problem that sometimes one day per week is not counted when calculating between two days.
attached pictures.

Does anyone know the solution to the problem?
Attachments
Screenshot 2024-02-01 162058.png
Screenshot 2024-02-01 162058.png (12.77 KiB) Viewed 222 times
Screenshot 2024-02-01 162252.png
Eric
Posts: 181
Joined: 25 Jun 2020, 13:40
Name: Eric Henrich
Location: Germany

Re: Calculation difference between date is not correct

Post by Eric »

Ist leider ein Fehler im System.

Weiteres kannst du auch hier nachlesen, aber kurz gesagt, Rukovoditel berücksichtigt Sommer und Winterzeit falsch bzw. nicht, was dann zu solchen Ergebnissen führt wie bei dir.
viewtopic.php?p=14422&hilit=days#p14422

Etwas näher beschrieben ist es so, das du in Rukovoditel eine Zeitzone in der Konfiguration angegeben hast, wenn du dann aber sowas wie die Funktion Days Difference benutzt, dann nimmt Rukovoditel den Server Timestamp, da aber in der Programmierung was fehlt oder fehlerhaft ist, rechnet das ganze dann nicht richtig, weil Sommer & Winterzeit nicht programmiert sind wie sie sollten, ich hoffe ich hab das verständlich beschrieben.
tolu77
Posts: 9
Joined: 03 Oct 2023, 19:59
Name: Thomas Ludwig
Location: Deutschland

Re: Calculation difference between date is not correct

Post by tolu77 »

Thank you for the explanation. After some trying, I found a solution for myself. I changed the start date for all entries from 00:00 to 04:00. The end date is 10:00 p.m. After that the calculation is correct for me. Now I have created an automatic process that monitors the table and changes the start and end dates accordingly.


$info_query = @db_query("SELECT * FROM `app_entity_52` WHERE NOT (HOUR(FROM_UNIXTIME(`field_611`)) = '4' AND MINUTE(FROM_UNIXTIME(`field_611`)) = '0')");
while ($info = @db_fetch_array($info_query))
{
$id= $info["id"];
$originalTimestamp = $info["field_611"];
$day = date('d', $originalTimestamp);
$month = date('m', $originalTimestamp);
$year = date('Y', $originalTimestamp);
// creating a new timestamp for the same day at 4:00 a.m
$newTimestamp = mktime(4, 0, 0, $monat, $tag, $jahr);
@db_query("UPDATE `app_entity_52` SET field_611='".$newTimestamp."' where id='".$id."' ");
}


$info_query = @db_query("SELECT * FROM `app_entity_52` WHERE NOT (HOUR(FROM_UNIXTIME(`field_612`)) = '22' AND MINUTE(FROM_UNIXTIME(`field_612`)) = '0')");
while ($info = @db_fetch_array($info_query))
{
$id= $info["id"];
$originalTimestampl = $info["field_612"];
$day = date('d', $originalTimestamp);
$month = date('m', $originalTimestamp);
$year = date('Y', $originalTimestamp);
// Creating a new timestamp for the same day at 10:00 p.m
$newTimestamp = mktime(22, 0, 0, $monat, $tag, $jahr);
@db_query("UPDATE `app_entity_52` SET field_612='".$newTimestamp."' where id='".$id."' ");
}
Post Reply