top of page

Comparing date with Today in Handlebars

Writer's picture: Kasper LarsenKasper Larsen

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}}


10 views0 comments

Recent Posts

See All

Comentarios


30103817

  • Twitter
  • LinkedIn

©2023 by M365thinking. Proudly created with Wix.com

bottom of page