---
title: "How to compare timestamp with the current time in gateway rules?"
description: "Comparing a timestamp with the current time in Geneos gateway rules can be done using the parseDate() and now() functions. You set rules by parsing the date string to epoch format and comparing it to now(), adjusting formats as needed."
url: "https://docs.itrsgroup.com/docs/faq/geneos/115004029549-geneos-how-to-compare-timestamp-with-the-current-time-in-gateway-rules/index.html"
---
You can make use of `parseDate()` and `now()` functions in gateway rules.

For example, the requirement is to check if a date (in a data cell) is 2 days past the current date. Sample value of cell is in the format: `2022-09-28 07:25:01`. Then you can set a rule:

```
set $(timenow) now() // this will get the current time at the point of execution expressed as seconds since the UNIX epoch.
set $(timedetected) parseDate("%Y-%m-%d %H:%M:%S", value) // this will convert the date into epoch format
if $(timenow) - $(timedetected) >= 172800 then
  severity critical
else
  severity ok
endif
```

Where `172800` represents the number of seconds for 2 days.

Sample output:

![ReceivedTime output](https://docscdn.itrsgroup.com/faq/images/geneos/received-time-output.png)

Right-click on the red cell and select **Show Rules**.

![Show Rules](https://docscdn.itrsgroup.com/faq/images/geneos/show-rules-gateway.png)

You just need to modify the string format in the parseDate function if you have a different date format. This can then be compared to the `now()` function which represents the current timestamp in epoch format.


**Note**



The reverse function for `parseDate()` is `printDate()`, which converts epoch timestamp to any format readable times using the same time formatting codes.




For more information, check the documentation about [parseDate() function](https://docs.itrsgroup.com/docs/geneos/current/processing/monitoring-and-alerts/geneos_rulesactionsalerts_tr/index.html#parsedate) and [Time formatting parsing codes](https://docs.itrsgroup.com/docs/geneos/current/processing/gateway-administration/geneos_timeformats_tr/index.html).


