diff --git a/include/class.ticket.php b/include/class.ticket.php
index dc0af339ee5b240812d3b6676f1c286b59193b6f..96c262ee6284d44c0160d8e304a39691516bfc75 100644
--- a/include/class.ticket.php
+++ b/include/class.ticket.php
@@ -1102,11 +1102,11 @@ class Ticket {
         $sql='UPDATE '.TICKET_TABLE.' SET isoverdue=0, updated=NOW() ';
 
         //clear due date if it's in the past
-        if($this->getDueDate() && strtotime($this->getDueDate())<=time())
+        if($this->getDueDate() && Misc::db2gmtime($this->getDueDate()) <= Misc::gmtime())
             $sql.=', duedate=NULL';
 
         //Clear SLA if est. due date is in the past
-        if($this->getSLADueDate() && strtotime($this->getSLADueDate())<=time())
+        if($this->getSLADueDate() && Misc::db2gmtime($this->getSLADueDate()) <= Misc::gmtime())
             $sql.=', sla_id=0 ';
 
         $sql.=' WHERE ticket_id='.db_input($this->getId());
@@ -1651,6 +1651,14 @@ class Ticket {
         $this->logNote('Ticket Updated', $vars['note'], $thisstaff);
         $this->reload();
 
+        //Clear overdue flag if duedate or SLA changes and the ticket is no longer overdue.
+        if($this->isOverdue()
+                && (!$this->getEstDueDate() //Duedate + SLA cleared
+                    || Misc::db2gmtime($this->getEstDueDate()) > Misc::gmtime() //New due date in the future.
+                    )) {
+            $this->clearOverdue();
+        }
+
         return true;
     }