diff --git a/includes/html/graphs/common.inc.php b/includes/html/graphs/common.inc.php
index 0c8f447b2a62..89aab5491c8f 100644
--- a/includes/html/graphs/common.inc.php
+++ b/includes/html/graphs/common.inc.php
@@ -3,11 +3,11 @@
use LibreNMS\Util\Clean;
if ($_GET['from']) {
- $from = (int)$_GET['from'];
+ $from = preg_match('/(-\d+[hdm]|now)/', $_GET['from']) ? $_GET['from'] : (int)$_GET['from'];
}
if ($_GET['to']) {
- $to = (int)$_GET['to'];
+ $to = preg_match('/(-?\d+[hdm]|now)/', $_GET['to']) ? $_GET['to'] : (int)$_GET['to'];
}
if ($_GET['width']) {