New to Telerik UI for ASP.NET AJAXStart a free 30-day trial

DateTimeFormatInfo object

The DateTimeFormatInfo object is used by the ASP NET AJAX Calendar control for formatting date and time values so that they reflect the current culture. It is accessible through the DateTimeFormatInfo property of the RadCalendar Client-side Object.

The DateTimeFormatInfo class is defined in the System.Globalization namespace.

The following table lists the methods of the DateTimeFormatInfo object:

NameParametersReturn TypeDescription
FormatDateArray (triplet), stringstringFormats a date, using the specified date and format string (see sample below).
LeadZerointegerstringFormats the integer, adding a leading zero if necessary so that the integer is a minimum of two digits.
JavaScript
<script type="text/javascript">
	function OnDateSelected(sender, e) {
        var calendarDay = e.get_renderDay();
        if (calendarDay.IsSelected) {
            var selectedDate = calendarDay.get_date();
            var calendar = $find("<%= RadCalendar1.ClientID %>");
            var shortDatePattern = calendar.DateTimeFormatInfo.ShortDatePattern;
            var formattedDate = calendar.DateTimeFormatInfo.FormatDate(selectedDate, shortDatePattern);
            alert(formattedDate);
        }
    }
</script>	

The following table lists the properties of the DateTimeFormatInfo object:

PropertytypeDescription
AbbreviatedDayNamesArrayLists the 3-letter abbreviations for the names of the days of the week, starting with the abbreviation for Sunday at element 0.
DayNamesArrayLists the names of the days of the week, starting with the name for Sunday at element 0.
AbbreviatedMonthNamesArrayLists the 3-letter abbreviations for the names of the months, starting with the abbreviation for January at element 0.
MonthNamesArrayLists the names of the months, starting with the name for January at element 0.
AMDesignatorStringThe string for the AM designator.
PMDesignatorStringThe string for the PM designator.
DateSeparatorCharacterThe separator character that appears between parts of a date.
TimeSeparatorCharacterThe separator character that appears between parts of a time value.
FirstDayOfWeekintegerThe index of the first day of the week, where 0 indicates Sunday.
FullDateTimePatternStringThe format string for the full date time pattern.
LongDatePatternStringThe format string for the long date pattern.
LongTimePatternStringThe format string for the long time pattern.
MonthDayPatternStringThe format string for the month day pattern.
ShortDatePatternStringThe format string for the short date pattern.
ShortTimePatternStringThe format string for the short time pattern.
YearMonthPatternStringThe format string for the year month pattern.
SortableDateTimePatternStringThe format string for the sortable date time pattern.
UniversalSortableDateTimePatternStringThe format string for the universal sortable date time pattern.
RFC1123PatternStringThe format string for the RFC 1123 pattern.
CalendarObjectA helper object for performing calculations about date and time values.
CalendarWeekRuleintegerUsed by the Calendar object to determine which week is the first week of the year.

See Also

In this article
See Also
Not finding the help you need?
Contact Support