Documentation for: ASP.NET Ajax Version 1.0

This documentation is for a previous version. For the current released version, see the ASP.NET Ajax documentation on MSDN.

 

 

 

 

 

 

 

Sys.CultureInfo.dateTimeFormat Field

Gets an object that contains an array of culture-sensitive formatting and parsing string values that can be applied to Date type extensions.

Syntax

var cultureObject = Sys.CultureInfo.CurrentCulture;
var dtfObject = cultureObject.dateTimeFormat;

Return Value

An object that contains an array of culture-sensitive formatting strings.

Remarks

Use the dateTimeFormat field to retrieve an object that contains an array of formatting strings that are based on the current culture or on the invariant culture. Each formatting string can be used to specify how to format Date type extensions.

Example

The following example shows how to use the dateTimeFormat field of the Sys.CultureInfo class based on the current culture. The culture attribute of the <configuration> section in the Web.config file must also be set to "auto". For more information about culture settings, see Globalizing a Date by Using Client Script.

cs

<script type="text/javascript">
    // Create the CurrentCulture object
    var cultureObject = Sys.CultureInfo.CurrentCulture;
// <Snippet4>
    // Get the name field of the CurrentCulture object
    var cultureName = cultureObject.name;
// <Snippet5>
    // Get the dateTimeFormat object from the CurrentCulture object
    var dtfObject = cultureObject.dateTimeFormat;
    // Create an array of format types
    var myArray = ['AMDesignator', 'Calendar', 'DateSeparator', 'FirstDayOfWeek',
                   'CalendarWeekRule', 'FullDateTimePattern', 'LongDatePattern', 
                   'LongTimePattern', 'MonthDayPattern', 'PMDesignator', 'RFC1123Pattern', 
                   'ShortDatePattern', 'ShortTimePattern', 'SortableDateTimePattern', 
                   'TimeSeparator', 'UniversalSortableDateTimePattern', 'YearMonthPattern', 
                   'AbbreviatedDayNames', 'ShortestDayNames', 'DayNames', 
                   'AbbreviatedMonthNames', 'MonthNames', 'IsReadOnly',
                   'NativeCalendarName', 'AbbreviatedMonthGenitiveNames', 
                   'MonthGenitiveNames'];

    var result = 'Culture Name: ' + cultureName;
    for (var i = 0, l = myArray.length; i < l; i++) {
        var arrayVal = myArray[i];
        if (typeof(arrayVal) !== 'undefined') {
            result += "<tr><td>" + arrayVal + "</td><td>" + eval("dtfObject." + arrayVal) + '</td></tr>';
        }
    }
    var resultHeader = "<tr><td><b>FormatType</b></td><td><b>FormatValue</b></td></tr>"
    $get('Label1').innerHTML = "<table border=1>" + resultHeader + result +"</table>";

    var d = new Date();
    $get('Label2').innerHTML = "<p/><h3>dateTimeFormat Example: </h3>" + 
    d.localeFormat(Sys.CultureInfo.CurrentCulture.dateTimeFormat.FullDateTimePattern);
 </script>

vb

<script type="text/javascript">
    // Create the CurrentCulture object
    var cultureObject = Sys.CultureInfo.CurrentCulture;
// <Snippet4>
    // Get the name field of the CurrentCulture object
    var cultureName = cultureObject.name;
// <Snippet5>
    // Get the dateTimeFormat object from the CurrentCulture object
    var dtfObject = cultureObject.dateTimeFormat;
    // Create an array of format types
    var myArray = ['AMDesignator', 'Calendar', 'DateSeparator', 'FirstDayOfWeek',
                   'CalendarWeekRule', 'FullDateTimePattern', 'LongDatePattern', 
                   'LongTimePattern', 'MonthDayPattern', 'PMDesignator', 'RFC1123Pattern', 
                   'ShortDatePattern', 'ShortTimePattern', 'SortableDateTimePattern', 
                   'TimeSeparator', 'UniversalSortableDateTimePattern', 'YearMonthPattern', 
                   'AbbreviatedDayNames', 'ShortestDayNames', 'DayNames', 
                   'AbbreviatedMonthNames', 'MonthNames', 'IsReadOnly',
                   'NativeCalendarName', 'AbbreviatedMonthGenitiveNames', 
                   'MonthGenitiveNames'];

    var result = 'Culture Name: ' + cultureName;
    for (var i = 0, l = myArray.length; i < l; i++) {
        var arrayVal = myArray[i];
        if (typeof(arrayVal) !== 'undefined') {
            result += "<tr><td>" + arrayVal + "</td><td>" + eval("dtfObject." + arrayVal) + '</td></tr>';
        }
    }
    var resultHeader = "<tr><td><b>FormatType</b></td><td><b>FormatValue</b></td></tr>"
    $get('Label1').innerHTML = "<table border=1>" + resultHeader + result +"</table>";

    var d = new Date();
    $get('Label2').innerHTML = "<p/><h3>dateTimeFormat Example: </h3>" + 
    d.localeFormat(Sys.CultureInfo.CurrentCulture.dateTimeFormat.FullDateTimePattern);
 </script>