locked
Where is DateTime.ToShortDateString equivalent in WinRT apps? RRS feed

  • Question

  • What is the WinRT equivalent for the DateTime.ToShortDateString() method?

    -- roschler

    Friday, January 24, 2014 11:12 PM

Answers

All replies

    • Marked as answer by roschler Saturday, January 25, 2014 3:09 AM
    Saturday, January 25, 2014 1:10 AM
    Moderator
  • Thanks Rob.  Can I rely on the following code to return the correct short date for the current locale, or is it not enough?

            public static string ToShortDateString(this DateTime dt)
            {
                DateTimeFormatter dtf = new DateTimeFormatter("shortdate");

                return dtf.Format(dt);
            }



    -- roschler

    Saturday, January 25, 2014 3:09 AM
  • public static String ToShortDateString(this DateTime date) {
                return date.ToString(System.Globalization.DateTimeFormatInfo.CurrentInfo.ShortDatePattern);
    }


    Enzo CONTINI

    Friday, November 7, 2014 2:40 PM