How to change Date/Time formats on the webshop

Blanca Castillo
Blanca Castillo
  • Updated

Where do I find it?

Configuration > Sales channels > Online-Shop (Desktop) > Integration

38db9e42-8704-4ddb-b8b9-9acd18bb6786.pnge9d918d2-0d22-4127-a305-0bb71ca8a5d3.png

 

What does it mean?

There are different date and time formats you can use on your webshop. There are some of them well-known like dd-MM-yyyy, where dd is the day, MM the month and yyyy the year, but there are a few more allowed possibilities. Here we show all of them.

 

What should I do?

Patterns

The following patterns can be used in these webshop detail settings:

Apart from d, M and y, there are more allowed symbols to use as part of a date or time. Here you can find all of them and some examples in the following table:

SymbolMeaningPresentationExample
Gera designatorTextAD
yyearNumber1996
Lstandalone month in yearText or NumberJuly (or) 07
Mmonth in yearText or NumberJuly (or) 07
dday in monthNumber10
hhour in am/pm (1-12)Number12
Hhour in day (0-23)Number0
mminute in hourNumber30
ssecond in minuteNumber55
Sfractional secondNumber978
Eday of weekTextTuesday
cstandalone day of weekTextTuesday
aam/pm markerTextPM
khour in day (1-24)Number24
Khour in am/pm (0-11)Number0
ztime zoneTextPacific Standard Time(see comment)
Ztime zone (RFC 822)Text-0800(See comment)
vtime zone idTextAmerica/Los_Angeles(See comment)
'escape for textDelimiter'Date='
''single quoteLiteral'o''clock'
 

The number of pattern letters also influences the format, as follows:

Text
If you use 4 or more letters, then the date or time is shown as the full form; if you use less than 4 letters, then the date or time is shown as the short or abbreviated form if it exists (e.g., "EEEE" produces "Monday", "EEE" produces "Mon").
 
 
Number
The minimum number of digits. Shorter numbers are zero-padded to this amount (e.g. if "m" produces "6", "mm" produces "06"). The year is handled specially; that is, if the count of 'y' is 2, the Year will be truncated to 2 digits. (e.g., if "yyyy" produces "20, "yy" produces "97".) Unlike other fields, fractional seconds are padded on the right with zero.
 
 
Text or Number
If you use 3 or more letters, then it produces a text, otherwise, it produces the corresponding number. (e.g. "M" produces "1", "MM" produces "01", "MMM" produces "Jan", and "MMMM" produces "January". Some pattern letters also treat a count of 5 specially, meaning a single-letter abbreviation: L, M, E, and c.

Any characters in the pattern that are not in the ranges of ['a '..'z'] and ['A'..'Z'] will be treated as quoted text. For instance, characters like ':', ' .', ' ' (space), '#' and ' @' will appear in the resulting time text even they are not embraced within single quotes.

In the date, you may use "/", "-", or a space between the day, month, and year numbers. For example:

  • dd/MM/yyyyor dd/MM/yy
  • dd-MM-yyyy or dd-MM-yy
  • dd MM yyyy or dd MM yy

 

Time Zone Handling

When you show a time string, for instance, your time departures, it is also possible to include information about the time zone. For formatting purposes, the following table shows the behavior of GWT DateTimeFormat.

PatternCommon TimeZoneSimple TimeZone
z, zz, zzzPDTUTC-7
zzzzPacific Daylight TimeUTC-7
Z, ZZ-0700-0700
ZZZ-07:00-07:00
ZZZZGMT-07:00GMT-07:00
v, vv, vvv, vvvvAmerica/Los_AngelesEtc/GMT+7
 

 

Examples

PatternFormatted Text
"yyyy.MM.dd G 'at' HH:mm:ss vvvv"2019.07.10 AD at 15:08:56 America/Los_Angeles
"EEE, MMM d, ''yy"Wed, July 10, '19
"h:mm a"12:08 PM
"hh 'o''clock' a, zzzz"12 o'clock PM, Pacific Daylight Time
"K:mm a, vvvv"0:00 PM, America/Los_Angeles
"yyyyy.MMMMM.dd GGG hh:mm aaa"02019.July.10 AD 12:08 PM

 

Parsing Considerations

When parsing a date string using the abbreviated year pattern ( "yy"), the parser must interpret the abbreviated year relative to some century. It does this by adjusting dates to be within 80 years before and 20 years after the time the parser instance is created. For example, using a pattern of "MM/dd/yy" and a date created on Jan 1, 2019, the string "01/11/21" would be interpreted as Jan 11, 2021, while the string "05/04/64" would be interpreted as May 4, 1964. During parsing, only strings consisting of exactly two digits will be parsed into the default century. If the year pattern does not have exactly two 'y' characters, the year is interpreted literally, regardless of the number of digits. For example, using the pattern "MM/dd/yyyy", "01/11/19" parses to Jan 11, 19 A.D.

When numeric fields about one another directly, with no intervening delimiter characters, they constitute a run of abutting numeric fields. Such runs are parsed specially. For example, the format "HHmmss" parses the input text "123456" to 12:34:56, parses the input text "12345" to 1:23:45, and fails to parse "1234". In other words, the leftmost field of the run is flexible, while the others keep a fixed width. If the parse fails anywhere in the run, then the leftmost field is shortened by one character, and the entire run is parsed again. This is repeated until either the parse succeeds or the leftmost field is one character in length. If the parse still fails at that point, the parse of the run fails.