Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Davide Oliva 35 posts 199 karma points
    Jul 17, 2012 @ 19:13
    Davide Oliva
    0

    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

  • Douglas Ludlow 210 posts 366 karma points
    Jul 17, 2012 @ 19:32
    Douglas Ludlow
    0

    You'll have to either cast the Value as a DateTime or use the Convert.ToDateTime() method:

    var dataNascita = Convert.ToDateTime(member.getProperty("dataNascita").Value.ToString());

    @dataNascita.ToString("dd/mm/yyyy")
  • Davide Oliva 35 posts 199 karma points
    Jul 18, 2012 @ 08:40
    Davide Oliva
    0

    Thank you very much, Douglas!

Please Sign in or register to post replies

Write your reply to:

Draft