Display last month

回答済み

2 コメント

  • Graeme Carmichael
    Community Moderator

    Rox

    I hope this works :) or perhaps someone can find a better way.

     

        {{'now' | date: "%B %Y" | date:"%s" | minus: 86400 | date: "%B %Y"  }}

     

    So what is happening is we find the start of the current month 

    • 'now' | date: "%B %Y" to give October 2019

    Then convert the date into seconds with:

    • date:"%s"

    Then subtract one day in seconds:

    • minus: 86400 where 24*60*60 is the seconds in a day

    Then finally format the whole thing to month and year

    • date: "%B %Y"
    3
  • Rox

    Hi Graeme,

    Thanks for the prompt reply.

    It worked!  Also, thank you so much for explaining each step in detail.  Very helpful!

    Much appreciated.

    Cheers,

    Rox

     

    -1

サインインしてコメントを残してください。

Powered by Zendesk