Format Date/Time in XAML in Silverlight

前端 未结 5 646
眼角桃花
眼角桃花 2020-12-08 00:02

I have a Silverlight 4 application. I have a C# DateTime object that I\'m binding to my UI. I want this DateTime to be in the format of dd/mm/yyyy time (TimeZon

5条回答
  •  盖世英雄少女心
    2020-12-08 00:41

    C#: try this

    • yyyy(yy/yyy) - years
    • MM - months(like '03'), MMMM - months(like 'March')
    • dd - days(like 09), ffffd/ffffdd - days(Sun/Sunday)
    • hh - hour 12(AM/PM), HH - hour 24
    • mm - minute
    • ss - second

    Use some delimeter,like this:

    1. MessageBox.Show(DateValue.ToString("yyyy-MM-dd")); example result: "2014-09-30"
    2. empty format string: MessageBox.Show(DateValue.ToString()); example result: "30.09.2014 0:00:00"

提交回复
热议问题