diff --git a/include/class.misc.php b/include/class.misc.php
index 0de812b734201d406817aadb952deb508832d1e7..d926200e4ea8c2911c196a5bc83d9b33101d9645 100644
--- a/include/class.misc.php
+++ b/include/class.misc.php
@@ -92,7 +92,10 @@ class Misc {
         if (is_int($timestamp)) {
             $time = $timestamp;
         } else {
-            $date = new DateTime($timestamp, $tz);
+            if (!($date = new DateTime($timestamp, $tz))) {
+                // Timestamp might be invalid
+                return $timestamp;
+            }
             $time = $date->format('U');
         }