I am trying to prevent my blog from showing posts from the future in the archive by comparing the date folder name which is already converted to a number to the year part of the current date.
How can I convert the year of the current date to a number?
I have tried FormatDateTime with yyyy and then cast to number but it didn't work. Any ideas?
I have managed to prevent future posts to show up on the homepage but this one is different.
You could probably make use of one of the date-compare functions, e.g.: DateGreaterThanOrEqualToday() or similar... that way you're using the actual date of the post(s) and not depending on them being in a correctly-named datefolder (even if that is automatically created).
E.g., to make sure you're not selecting any future posts, start by creating a currentPosts variable:
Convert date to number
Hello,
I am trying to prevent my blog from showing posts from the future in the archive by comparing the date folder name which is already converted to a number to the year part of the current date.
How can I convert the year of the current date to a number?
I have tried FormatDateTime with yyyy and then cast to number but it didn't work. Any ideas?
I have managed to prevent future posts to show up on the homepage but this one is different.
Hi Alexandru
Have you try something like
<xsl:value-of select="umbraco.library:FormatDateTime(@createDate, 'dd MMMM, yyyy')" disable-output-escaping="yes"/>
Hi Alexandru,
You could probably make use of one of the date-compare functions, e.g.: DateGreaterThanOrEqualToday() or similar... that way you're using the actual date of the post(s) and not depending on them being in a correctly-named datefolder (even if that is automatically created).
E.g., to make sure you're not selecting any future posts, start by creating a currentPosts variable:
and later base all other filtering on that one, e.g.:
/Chriztian
Oh - but to answer your real question, this should give you a number:
(It depends, I know, but you hardly ever need to do this in XSLT...)
/Chriztian
Thanks for the reply guys!
Problem solved :D
is working on a reply...