.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> DateTime >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Date time format information

Posted By:shankey       Posted Date: July 28, 2011    Points: 40    Category: DateTime    URL: http://www.dotnetspark.com  

List of date time format that will help you to bind appropriate pattern to field.
 

DateTimeFormatInfo

Hi All following is the list of date time format that will help you to bind appropriate pattern to field.


Following is the example of how to bind date time field to a template field in a grid.


<asp:TemplateField HeaderText="End Date"> <ItemTemplate>


<asp:TextBox runat="server" ID="Txt_End_Date" Width="60%" Text='<%# DataBinder.Eval (Container.DataItem, "DateEnded", "{0:d}") %>' />
  ItemTemplate> asp:TemplateField>


In the above template field "d" format of date time is used to display only date. Following are list of date time format that will help you to select and set appropriate pattern to field.

Ø  Format= Description
Ø  d = ShortDatePattern
Ø  D = LongDatePattern
Ø  f = Full date and time (long date and short time)
Ø  F = FullDateTimePattern (long date and long time)
Ø  g = General (short date and short time)
Ø  G = General (short date and long time)
Ø  m, M = MonthDayPattern
Ø  r, R = RFC1123Pattern
Ø  s = SortableDateTimePattern (based on ISO 8601) using local time
Ø  t = ShortTimePattern
Ø  T = LongTimePattern
Ø  u = UniversalSortableDateTimePattern using the format for universal time display
Ø  U = Full date and time (long date and long time) using universal time
Ø  y, Y = YearMonthPattern

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend