Question: I have a date field on a node – set to a custom date format (*c* which is ISO) in the Manage Display.
I have a twig template checking to see if that date field comes before today, in which is should output *Past*.
Outputting the fields/comparison values gets me the properly formatted dates I want to compare.

```
{{ content.field_closing_date.0 }}
{{ 'now'|date('c') }}

```

which outputs

```
2021-05-05T16:30:00-07:00
2021-05-14T12:01:53-07:00

```

My comparison is

```
{% if 'now'|date('c') > content.field_closing_date.0 %}
Past
{% endif %}

```

But it's not outputting *Past*. What gives?
You can see that the todays date *does* come after the date field.

Answer: 
If you feel like a preprocess function is overload and if you can afford to ignore timezones, try converting both date values to **U**nix timestamps to make them properly comparable. And prefer raw node values over formatted content values:

```
{% if ('now'|date('U') > node.field_closing_date.0.value|date('U')) %}
  Past
{% endif %}

```
This is my code to compare current time with a date field

```
{% if content.field_expired_date.0['#markup']|date('U') >= "now"|date('U') %}
    Hello Future 
{% endif %}

```