Thursday, January 15, 2009

A Date Format Calendar of the Asp.net

ToFileTime: Converts the selection to the local operating system file time:127473912000000000.
long tofiletime = Convert.ToInt64(Calendar1.TodaysDate.ToFileTime().ToString());
lblCalendar.Text = "The date format is " + tofiletime.ToString();
ToFileTimeUtc: Converts the selection to the operating system file time, but instead of using the local time zone, the UTC time is used: 127473696000000000.
long tofiletimeutc = Convert.ToInt64(Calendar1.TodaysDate.ToFileTimeUtc().ToString());
lblCalendar.Text = "The date format is " + tofiletimeutc.ToString();
ToLocalTime: Converts the current coordinated universal time (UTC) to local time:12/12/2004 6:00:00 PM.
DateTime localTime = Convert.ToDateTime(Calendar1.TodaysDate.ToLocalTime().ToString());
lblCalendar.Text = "The date format is " + localTime.ToString();
ToLongDateString: Converts the selection to a human-readable string in a long format:Monday, December 13, 2004.
System.DateTime dTime = new System.DateTime(2001, 5, 16, 3, 2, 15);

lblCalendar3.Text = "The Long Date format is " + dTime.ToLongDateString() + "
";
ToLongTimeString: Converts the selection to a time value (no date is included) of a long format:12:00:00 AM.
System.DateTime dTime = new System.DateTime(2001, 5, 16, 3, 2, 15);
lblCalendar4.Text = "The Long Time format is " + dTime.ToLongTimeString() + "
";
ToOADate: Converts the selection to an OLE Automation date equivalent: 38334.
This was previously used in .net 1.1.
ToShortDateString: Converts the selection to a human-readable string in a short format:12/13/2004.
System.DateTime dTime = new System.DateTime(2001, 5, 16, 3, 2, 15);
lblCalendar5.Text = "The Short Date format is " + dTime.ToShortDateString() + "
";
ToShortTimeString: Converts the selection to a time value (no date is included) in a short format:12:00 AM.
System.DateTime dTime = new System.DateTime(2001, 5, 16, 3, 2, 15);
lblCalendar6.Text = "The Short Time format is " + dTime.ToShortTimeString() + "
";
ToString: Converts the selection to the following: 12/13/2004 12:00:00 AM.
System.DateTime dTime = new System.DateTime(2001, 5, 16, 3, 2, 15);
lblCalendar7.Text = "The ToString Time format is " + dTime.ToString() + "
";
ToUniversalTime: Converts the selection to universal time (UTC): 12/13/2004 6:00:00 AM.
System.DateTime dTime = new System.DateTime(2001, 5, 16, 3, 2, 15);

lblCalendar7.Text = "The Universal Time format is " + dTime.ToUniversalTime() + "
";

No comments:

Post a Comment