HI WELCOME TO KANSIRIS

Format Date/Time in XAML

Leave a Comment
<TextBlock Text="{Binding Date, StringFormat='{}{0:MM/dd/yyyy a\\t h:mm tt}'}" />
will return you
04/07/2011 at 1:28 PM (-04)

The date formatting has a huge range of options.
For the DateTime of “April 17, 2004, 1:52:45 PM”
You can either use a set of standard formats (standard formats)…
StringFormat=f : Saturday, April 17, 2004 1:52 PM
StringFormat=g : 4/17/2004 1:52 PM
StringFormat=m : April 17
StringFormat=y : April, 2004
StringFormat=t : 1:52 PM
StringFormat=u : 2004-04-17 13:52:45Z
StringFormat=o : 2004-04-17T13:52:45.0000000
… or you can create your own date formatting using letters (custom formats)
StringFormat=’MM/dd/yy : 04/17/04
StringFormat=’MMMM dd, yyyy g : April 17, 2004 A.D.”
StringFormat=’hh:mm:ss.fff tt : 01:52:45.000 PM

0 comments:

Post a Comment

Note: only a member of this blog may post a comment.