I'm trying to format a member date of birth property (data type datepicker) that currently it displays as dd/mm/yyyy hh:mm in dd/mm/yyyy format.
My code is:
var dataNascita = member.getProperty("dataNascita").Value.ToString("dd/mm/yyyy");
but it doesn't works and not even works this code:
@dataNascita.FormatDateTime("dd/mm/yyyy")
Someone of you dear fellow members of Umbraco community has an idea about this little trouble? Sorry for my bad english. I hope this post was understandable.
Formatting date (umbraco 4.7.2)
Hi all!
I'm trying to format a member date of birth property (data type datepicker) that currently it displays as dd/mm/yyyy hh:mm in dd/mm/yyyy format.
My code is:
var dataNascita = member.getProperty("dataNascita").Value.ToString("dd/mm/yyyy");
but it doesn't works and not even works this code:
@dataNascita.FormatDateTime("dd/mm/yyyy")
Someone of you dear fellow members of Umbraco community has an idea about this little trouble?
Sorry for my bad english. I hope this post was understandable.
Thanks in advance.
Davide
You'll have to either cast the Value as a DateTime or use the Convert.ToDateTime() method:
Thank you very much, Douglas!
is working on a reply...