Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Format Date/Time in XAML in Silverlight

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 (TimeZone). For instance, today would be displayed as

04/07/2011 at 01:13 p.m. (EST) 

Is there a way to do this XAML? Or do I need to build a converter?

like image 864
user687554 Avatar asked Apr 07 '11 17:04

user687554


People also ask

What is T and Z in time format?

What is T between date and time? The T is just a literal to separate the date from the time, and the Z means “zero hour offset” also known as “Zulu time” (UTC). If your strings always have a “Z” you can use: SimpleDateFormat format = new SimpleDateFormat( “yyyy-MM-dd'T'HH:mm:ss).

What formats for displaying date and time?

The dates appear as, mm/dd/yyyy in the U.S. and as, dd/mm/yyyy outside the U.S. where mm is the month, dd is the day, and yyyy is the year. The time is displayed as, hh:mm:ss AM/PM, where hh is the hour, mm is minutes, and ss is seconds.

What is the universal date format?

The ISO standard takes a general-to-specific approach for its date formats: The year comes first, followed by the month and then by the day of the month, with most elements represented as numerical values. For example, the ISO representation for July 15, 2022 is either 20220715 or 2022-07-15.


1 Answers

<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)

like image 75
Vlad Bezden Avatar answered Sep 30 '22 21:09

Vlad Bezden