Common GlideDateTime format string pitfalls and symbol reference<!-- /*NS Branding Styles*/ --> .ns-kb-css-body-editor-container { p { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } span { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } h2 { font-size: 24pt; font-family: Lato; color: var(--now-color--text-primary, black); } h3 { font-size: 18pt; font-family: Lato; color: var(--now-color--text-primary, black); } h4 { font-size: 14pt; font-family: Lato; color: var(--now-color--text-primary, black); } a { font-size: 12pt; font-family: Lato; color: var(--now-color--link-primary, #00718F); } a:hover { font-size: 12pt; color: var(--now-color--link-primary, #024F69); } a:target { font-size: 12pt; color: var(--now-color--link-primary, #032D42); } a:visited { font-size: 12pt; color: var(--now-color--link-primary, #00718f); } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } Identify and avoid common GlideDateTime format string pitfalls that can produce unexpected behavior. When an incorrect format string is passed to GlideDateTime, the results can appear to be a platform bug but are typically caused by incorrect or ambiguous pattern symbol casing. In practice, the most common issues involve using the wrong case for year, hour, minute, and time zone symbols. Common format string pitfalls The following table shows common format string errors and their corrections. PitfallIncorrectCorrectExplanationUppercase year symbolYYYY-MM-dd HH:mm:ssyyyy-MM-dd HH:mm:ssYYYY is the week year, not the calendar year. Use yyyy for calendar year.Mixed 12-hour and 24-hour symbolsHH:mm:ss a or hh:mm:sshh:mm:ss a or HH:mm:ssHH is 24-hour time (0–23). hh is 12-hour time (1–12). Do not use a (AM/PM marker) with HH or kk.Ambiguous time zone abbreviationHH:mm:ss zHH:mm:ss zzzzA single z produces non-unique abbreviations — for example, IST can mean India Standard Time or Israel Standard Time. Use zzzz for the full time zone name.Using MM for both month and minuteMM-dd-yyyy HH:MMMM-dd-yyyy HH:mmMM is the month symbol. mm is the minute symbol. Using MM in the time portion returns the month value instead of the minute value.Using DDD for day of the monthyyyy-DDD-MMyyyy-MM-ddDDD is the day of the year (1–365), not the day of the month. Use dd for the day of the month. Symbol guide The following table describes the pattern symbols used in GlideDateTime format strings. These symbols follow the Java SimpleDateFormat specification. SymbolMeaningExampleNotesGEra designatorAD yCalendar year1996; 96Use this for calendar year.YWeek year2009; 09Week year differs from calendar year. Avoid using Y unless specifically working with ISO week dates.MMonth in yearJuly; Jul; 07 wWeek in year27 WWeek in month2 DDay in year189Returns the day of the year (1–365), not the day of the month.dDay in month10Use this for the day of the month.FDay of week in month2 EDay name in weekTuesday; Tue uDay number of week11 = Monday, 7 = SundayaAM/PM markerAMDo not use with H or k (24-hour symbols).HHour in day (0–23)024-hour clock. Do not use with a.kHour in day (1–24)124-hour clock. Do not use with a.KHour in AM/PM (0–11)012-hour clock. Use with a.hHour in AM/PM (1–12)112-hour clock. Use with a.mMinute in hour30 sSecond in minute55 SMillisecond978 zGeneral time zonePST; GMT-08:00Avoid single z — abbreviations are not unique. Use zzzz for the full time zone name. For more information about date and time pattern symbols, see the Date and Time Patterns section of the Java SimpleDateFormat documentation.