Copied to clipboard

Flag this post as spam?

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

  • Roger Withnell 127 posts 612 karma points
    Nov 13, 2015 @ 13:01
    Roger Withnell

    Format date picker property

    I'm using MVC Razor.

    I have my date picker field with:


    How do I now format it? I want dd-MM-yyyy.

    I cant' make .ToString("dd-MM-yyyy") work.

    Your help would be much appreciated.

    Thanking you in anticipation.


  • Per Olsson 47 posts 307 karma points
    Nov 13, 2015 @ 13:11
    Per Olsson

    Use the Umbraco Helper.

    umbraco.library.FormatDateTime(Model.Content.GetPropertyValue("date").ToString(), "dd-MM-yyyy")

  • M N 125 posts 212 karma points
    Oct 25, 2017 @ 16:13
    M N

    Value Converter approach if you prefer to use built-in .net helpers.

    DateTime date = Model.Content.GetPropertyValue<DateTime>("date");

    and in your view

    <p>Date: @date.ToString("dd-MM-yyyy")</p>
Please Sign in or register to post replies

Write your reply to: