Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
HelloHow do I use ToString in the code below (should be used on the "date")?
<div class="blog-content"> <div class="title"> <span>@news.GetProperty("date").Value</span> <h2><a href="single-post.html"></a>@news.GetProperty("headline").Value</h2> </div> <p>@news.GetProperty("description").Value</p></div>
I have tried this with no luck:
<div class="blog-content"> <div class="title"> <span>@news.GetProperty("date").Value</span> <h2><a href="single-post.html"></a>@news.GetProperty("headline").Value.ToString("dd-MM-yyyy")</h2> </div> <p>@news.GetProperty("description").Value</p></div>
Thanks in advance!// René
Hi René
Maybe this post can help you out here. It sems to be the same issue.
http://our.umbraco.org/forum/developers/razor/19260-how-do-I-format-datetime-in-razor
/Dennis
Isn't it the wrong property you are trying to format? I guess the property "headline" isn't a datetime..?
Try with the date property:
<div class="blog-content"> <div class="title"> <span>@news.GetProperty("date").Value.ToString("dd-MM-yyyy")</span> <h2><a href="single-post.html"></a>@news.GetProperty("headline").Value</h2> </div> <p>@news.GetProperty("description").Value</p> </div>
/Bjarne
Hi DennisThanks!I solved the problem with some minor changes in the code see below:
<divclass="blog-content"> <divclass="title"> <span>@news.date.ToString("dd-MM-yyyy")</span> <h2><ahref="single-post.html"></a>@news.headline</h2> </div> <p>@news.description</p></div>
// René
Hi BjarneSorry I made some changes from my original code before i posted it here and by i mistake I put in the ToString command the wrong place.// René
I'm glad you solved it.. please mark the right answer as solution :)
Perhaps this is just a typing mistake, but I think you want to wrap anchor tag around the news headline?
Then it should be:
<div class="blog-content"> <div class="title"> <span>@news.date.ToString("dd-MM-yyyy")</span> <h2><a href="single-post.html">@news.headline</a></h2> </div> <p>@news.description</p> </div>
Hi BjarneYep that was a typing mistake but thanks anyway. :-)// René
is working on a reply...
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.
Continue discussion
How to use ToString("dd-MM-yyyy")
Hello
How do I use ToString in the code below (should be used on the "date")?
I have tried this with no luck:
Thanks in advance!
// René
Hi René
Maybe this post can help you out here. It sems to be the same issue.
http://our.umbraco.org/forum/developers/razor/19260-how-do-I-format-datetime-in-razor
/Dennis
Hi René
Isn't it the wrong property you are trying to format? I guess the property "headline" isn't a datetime..?
Try with the date property:
/Bjarne
Hi Dennis
Thanks!
I solved the problem with some minor changes in the code see below:
// René
Hi Bjarne
Sorry I made some changes from my original code before i posted it here and by i mistake I put in the ToString command the wrong place.
// René
Hi René
I'm glad you solved it.. please mark the right answer as solution :)
Perhaps this is just a typing mistake, but I think you want to wrap anchor tag around the news headline?
Then it should be:
/Bjarne
Hi Bjarne
Yep that was a typing mistake but thanks anyway. :-)
// René
is working on a reply...
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.