diff --git a/include/simpleplugin/class_attribute.inc b/include/simpleplugin/class_attribute.inc
index b1d0e7631c7d52aacbfd1a3802a14f1152d6e63f..ce22c83986dd735fdc4ce5f23a6f8cfcd5dc40e5 100644
--- a/include/simpleplugin/class_attribute.inc
+++ b/include/simpleplugin/class_attribute.inc
@@ -1488,9 +1488,17 @@ class DateAttribute extends Attribute
     if ($this->value === "" && !$this->isRequired()) {
       return $this->value;
     } elseif (!($this->value instanceof DateTime)) {
-      $this->setValue($this->getDateValue());
+      try {
+        $this->setValue($this->getDateValue());
+        return $this->dateToLdap($this->value);
+      } catch (Exception $e) {
+        if (is_object($this->plugin) && $this->plugin->is_template) {
+          return $value;
+        } else {
+          throw $e;
+        }
+      }
     }
-    return $this->dateToLdap($this->value);
   }
 
   function check ()