How do I format a string to display date and time as
06-Apr-2009 04:25 PM
Can any One help?
Thanks
How do I format a string to display date and time as
06-Apr-2009 04:25 PM
Can any One help?
Thanks
you can check out the available DateTime formats at http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx you can also provide custom formats. if you want to display it within wpf when dealing with DateTime's, you can implement a custom IValueConverter and use the Converter within your binding to display the datetime's as you want them.
You can use a custom date format string to get exactly that format:
theDate.ToString("dd'-'MMM'-'yyyy HH':'mm tt")
WPF now has the StringFormat
property on the Binding
class, which you can use as follows:
<TextBlock Text="{Binding StringFormat={}{0:dd-MMM-yyyy HH:mm tt}}"/>
HTH, Kent