Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Paul Marden 235 posts 338 karma points MVP 2x c-trib
    Nov 11, 2011 @ 02:18
    Paul Marden
    0

    Using umbraco.library:DateDiff and CurrentDate

    I want to count the number of days between now and a date in the future.  I can ruddy figure out if I can pass the output of CurrentDate to DateDiff.

    Can anyone help?

  • Dan Okkels Brendstrup 101 posts 197 karma points
    Nov 11, 2011 @ 07:58
    Dan Okkels Brendstrup
    2

    Yes, that'll work:

    <xsl:template match="/">
      <xsl:variable name="currentDate" select="substring-before(umbraco.library:CurrentDate(), 'T')"/>
      <xsl:variable name="futureDate" select="'2011-12-11'"/>
      <xsl:variable name="diffSeconds" select="umbraco.library:DateDiff($futureDate, $currentDate, 's')"/>
      <p>Diff in days: <xsl:value-of select="floor($diffSeconds div (60 * 60 * 24))"/></p>
    </xsl:template>

    If your date includes a time, then remove the "substring-before" from $currentDate and add a time to the $futureDate, e.g. '2011-12-11T16:00:00'.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies