Introduction


The default date/time format for all WIN-911 notifier formats is the long time format (a culture specific representation that includes seconds, e.g. "1:45:30 PM", "13:45:30", "01:45:30"). In some cases, you may want to use a different format that doesn't include seconds or also includes the date. You can do this by copying an existing notifier format and changing the date/time format specifier. 


A table of all available date/time format specifiers can be found at the end of this article.


Changing the Date/Time Format Specifier


In the following example I will use an Email format but the process is the same for all notifiers. The goal of this example is to change the time format to not include seconds, so the desired output would be "9:53 AM". This is done by changing the date/time specifer


  • Open the WIN-911 Configuration GUI and navigate to Contact -> Email -> Formats
  • Select a format in the collection selector on the left that you would like to change.
  • If you selected a custom format, you can click the Edit button on the bottom right, if you selected a built-in format, you'll need to select the Create Copy icon on the bottom left.
  • Locate the <ms:script> element in the format, it should be near the top.

    <ms:script language="C#" implements-prefix="specter">
        <![CDATA[              
             public string localTime(String str)
             {
          DateTime dt = DateTime.Parse(str);
                return dt.ToLocalTime().ToString("T");
             }
        ]]>
      </ms:script>
     
  • The date/time format specifier is the "T" located in the following line, return dt.ToLocalTime().ToString("T");

  • Using the Date/Time Format Specifer table below, I know I need to change the uppercase T to a lowercase t to achieve the desired format.

  • Make the change and save the format. You will see a preview of the new time format on the right side of the screen. 

  • Apply your new format to your Email Connections.


Date/Time Specifiers



Specifier
Description
Examples
"d"
Short date pattern.
6/15/2009 (en-US)

15/06/2009 (fr-FR)

2009/06/15 (ja-JP)
"D"
Long date pattern.
Monday, June 15, 2009 (en-US)

15 июня 2009 г. (ru-RU)

Montag, 15. Juni 2009 (de-DE)
"f"
Full date/time pattern (short time).
Monday, June 15, 2009 1:45 PM (en-US)

den 15 juni 2009 13:45 (sv-SE)

Δευτέρα, 15 Ιουνίου 2009 1:45 μμ (el-GR)
"F"
Full date/time pattern (long time).
Monday, June 15, 2009 1:45:30 PM (en-US)

den 15 juni 2009 13:45:30 (sv-SE)

Δευτέρα, 15 Ιουνίου 2009 1:45:30 μμ (el-GR)
"g"
General date/time pattern (short time).
6/15/2009 1:45 PM (en-US)

15/06/2009 13:45 (es-ES)

2009/6/15 13:45 (zh-CN)
"G"
General date/time pattern (long time).
6/15/2009 1:45:30 PM (en-US)

15/06/2009 13:45:30 (es-ES)

2009/6/15 13:45:30 (zh-CN)
"M", "m"
Month/day pattern.
June 15 (en-US)

15. juni (da-DK)

15 Juni (id-ID)
"O", "o"
Round-trip date/time pattern.
DateTime values:

2009-06-15T13:45:30.0000000-07:00

2009-06-15T13:45:30.0000000Z

2009-06-15T13:45:30.0000000

DateTimeOffset values:

2009-06-15T13:45:30.0000000-07:00
"R", "r"
RFC1123 pattern.
Mon, 15 Jun 2009 20:45:30 GMT
"s"
Sortable date/time pattern.
2009-06-15T13:45:30

2009-06-15T13:45:30
"t"
Short time pattern.
1:45 PM (en-US)

13:45 (hr-HR)

01:45 م (ar-EG)
"T"
Long time pattern.
1:45:30 PM (en-US)

13:45:30 (hr-HR)

01:45:30 م (ar-EG)
"u"
Universal sortable date/time pattern.
With a DateTime value: 2009-06-15 13:45:30Z

With a DateTimeOffset value: 2009-06-15 20:45:30Z
"U"
Universal full date/time pattern.
Monday, June 15, 2009 8:45:30 PM (en-US)

den 15 juni 2009 20:45:30 (sv-SE)

Δευτέρα, 15 Ιουνίου 2009 8:45:30 μμ (el-GR)
"Y", "y"
Year month pattern.
June, 2009 (en-US)

juni 2009 (da-DK)

Juni 2009 (id-ID)
Any other single character
Unknown specifier.
Throws a run-time FormatException.