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
Hi,
Has the FormatDateTime() method changed in Umbrac v6 ?
this used to work:
umbraco.library.FormatDateTime(article.GetPropertyValue("mediaArticlePublicationDate"), "dd/MM/yyyy")
now I'm getting this error message in VS
Error 226 The best overloaded method match for 'umbraco.library.FormatDateTime(string, string)' has some invalid arguments c:\Repos\cjs_cms\Views\MacroPartials\MediaArticleList.cshtml 36 21 C:\Repos\cjs_cms\
found out that this works:
@if (article.HasValue("mediaArticlePublicationDate"))
{
string date = article.GetPropertyValue("mediaArticlePublicationDate").ToString();
@umbraco.library.FormatDateTime(date, "dd/MM/yyyy");
}
Hi Anthony I would use something like this if you are using umbraco 6 with strongly typed.
@if(article.HasValue("mediaArticlePublicationDate") { @(article.GetPropertyValue<DateTime>("mediaArticlePublicationDate").ToString("dd/MM/yyyy")) }
Hi Ali,
Thanks for the tip. I tried this:
<dd><time datetime="@Model.Content.GetPropertyValue<DateTime>("mediaArticlePublicationDate").ToString("dd/MM/yyyy")"></time>...</dd>
though the compiler is complaining:
Error1Cannot convert method group 'GetPropertyValue' to non-delegate type 'object'. Did you intend to invoke the method?
this will sort it out:
when you use <> within the markup you need to wrap razor with ()
<dd> <time datetime="@(Model.Content.GetPropertyValue<DateTime>("mediaArticlePublicationDate").ToString("dd/MM/yyyy"))"></time> </dd>
oh I see. Thanks a lot, it's working now : )
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
cannot format DateTime using umbraco.library.FormatDateTime()
Hi,
Has the FormatDateTime() method changed in Umbrac v6 ?
this used to work:
umbraco.library.FormatDateTime(article.GetPropertyValue("mediaArticlePublicationDate"), "dd/MM/yyyy")
now I'm getting this error message in VS
Error 226 The best overloaded method match for 'umbraco.library.FormatDateTime(string, string)' has some invalid arguments c:\Repos\cjs_cms\Views\MacroPartials\MediaArticleList.cshtml 36 21 C:\Repos\cjs_cms\
found out that this works:
@if (article.HasValue("mediaArticlePublicationDate"))
{
string date = article.GetPropertyValue("mediaArticlePublicationDate").ToString();
@umbraco.library.FormatDateTime(date, "dd/MM/yyyy");
}
Hi Anthony I would use something like this if you are using umbraco 6 with strongly typed.
Hi Ali,
Thanks for the tip. I tried this:
<dd><time datetime="@Model.Content.GetPropertyValue<DateTime>("mediaArticlePublicationDate").ToString("dd/MM/yyyy")"></time>...</dd>
though the compiler is complaining:
Error1Cannot convert method group 'GetPropertyValue' to non-delegate type 'object'. Did you intend to invoke the method?
this will sort it out:
when you use <> within the markup you need to wrap razor with ()
oh I see. Thanks a lot, it's working now : )
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.