Copied to clipboard

Flag this post as spam?

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


  • Martin Rud 261 posts 1022 karma points c-trib
    Jun 24, 2020 @ 05:08
    Martin Rud
    0

    Trying to format date from Umbraco.DateTime property gives "No overload for method 'ToString' takes 1 arguments"

    I have the following code:

    timespan.Value("startTime").ToString("d. MMMM yyyy kl. HH.mm");
    

    Where timespan.Value("startTime") comes from an Umbraco.DateTime property.

    This gives me the error: "No overload for method 'ToString' takes 1 arguments".

    How can I format the date without errors?

  • Jan Hansen 20 posts 50 karma points
    Jun 24, 2020 @ 06:28
    Jan Hansen
    100

    Did you try casting, converting or specifying the DateTime?

    timespan.Value<DateTime>(...).ToString(...)
    
    ((DateTime)timespan.Value(...)).ToString(...)
    
    Convert.ToDateTime(timespan.Value(...)).ToString(...)
    
  • Martin Rud 261 posts 1022 karma points c-trib
    Jun 24, 2020 @ 08:10
    Martin Rud
    0

    Cool - that works for me:

    var startTime = timespan.Value<DateTime>("startTime");
    var startTimeString = startTime.ToString("d. MMMM kl. HH.mm");
    
  • 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.

Please Sign in or register to post replies