I guess both suggestions will solve my problem, but I have chosen Toms suggestion. I will give you both a high five :)
Tom, somehow I get this output: aug09-08-20112011 That's a bit weird with the day format.. it looks similar to the the way I formattet the day before, but I don't get just a 9 but the whole date: 09-08-2011 ... hmm
It gives me a xslt error popup bubble, when saving with d, but it works with dd . But then I get 09 .. and in this case I think it looks better with just a 9.
That's really weird, I get the same results when using 'd' but 'dd' works.
In leiu of finding the actual problem/fix, you could do a cheesy workaround by using 'dd' and testing for the leading 0 and remove it if needed. Or Chriztian might have a better way :)
Good find Chriztian! Very weird, so I guess there's no built in way to use 'd' without a hack like the above. Perhaps that should be updated at some point...
Styling a date
Hi
I have a news date in my xslt like this:
<p class="news_date"><xsl:value-of select="umbraco.library:FormatDateTime(./newsDate, 'd MMM yyyy')"/></p>
But how can I e.g. wrap the day inside a span tag and the same with month and year, so I am able to style day, month and year in different ways?
So I will have a look like the icon above from the CWS project..
Bjarne
Hi Bjarne,
You can use the format string to pull just the parts you need, and write them out separately, eg:
Then of course you can use CSS to target each separately and layout the way you like.
Hope this helps,
Tom
Hi Bjarne,
I'd do something like this:
- and then use it like this:
/Chriztian
Hi both..
I guess both suggestions will solve my problem, but I have chosen Toms suggestion.
I will give you both a high five :)
Tom, somehow I get this output: aug09-08-20112011
That's a bit weird with the day format.. it looks similar to the the way I formattet the day before, but I don't get just a 9 but the whole date: 09-08-2011 ... hmm
Bjarne
Sounds like the format string might be messed up? Are you just using 'd'? Maybe try dd just to test? Maybe paste your code here also
I have this in my xslt:
<p class="news_date">
<span class="month"><xsl:value-of select="umbraco.library:FormatDateTime(./newsDate, 'MMM')"/></span>
<span class="day"><xsl:value-of select="umbraco.library:FormatDateTime(./newsDate, 'd')"/></span>
<span class="year"><xsl:value-of select="umbraco.library:FormatDateTime(./newsDate, 'yyyy')"/></span>
</p>
It gives me a xslt error popup bubble, when saving with d, but it works with dd .
But then I get 09 .. and in this case I think it looks better with just a 9.
That's really weird, I get the same results when using 'd' but 'dd' works.
In leiu of finding the actual problem/fix, you could do a cheesy workaround by using 'dd' and testing for the leading 0 and remove it if needed. Or Chriztian might have a better way :)
-Tom
Thanks for the workaround Tom..
That might be a fix of the problem..
I have tried another way too, with a empty space:
<p class="news_date">
<span class="day"><xsl:value-of select="umbraco.library:FormatDateTime(./newsDate, ' d')"/></span>
<span class="month"><xsl:value-of select="umbraco.library:FormatDateTime(./newsDate, 'MMM')"/></span>
<span class="year"><xsl:value-of select="umbraco.library:FormatDateTime(./newsDate, 'yyyy')"/></span>
</p>
It doesn't have any particular importance for the frontend look, just that a get a empty space in the code: <span class="day"> 9</span>
If one of you find any solutions of that strange bug, let me know :)
Bjarne
Strange. In that case you could just wrap the call in Replace to replace the space if needed:
Glad you got it figured out!
-Tom
Thanks :)
I works great now..
Bjarne
Hi Tom+Bjarne,
The 'd' is a special case of the FormatDateTime() function - it returns a "Short date format for current culture"
/Chriztian
Good find Chriztian! Very weird, so I guess there's no built in way to use 'd' without a hack like the above. Perhaps that should be updated at some point...
-Tom
is working on a reply...