Comparing date with Today in Handlebars
- Kasper Larsen
- Jan 28
- 1 min read
While working on a PnP Modern Search based overview of HR Policies, I realized how tricky it can be to compare a date with "Today" in a handlebar.
In this case I wanted to color code the review date, as it should be red if the date has been exceeded.

It seens like the best option is to use Moment js and compare the tick values:
{{#lt (getDate ValidUntilDateOWSDATE 'X') (moment 'X')}}
<span style= "color: Red">
{{getDate ValidUntilDateOWSDATE 'LL'}}
</span>
{{else}}
<span style= "color: black">
{{getDate ValidUntilDateOWSDATE 'LL'}}
</span>
{{/lt}}
Commentaires