This Date format issue I am going to talk about is in WebForm for marketers module 2.4. for Sitecore. Recently, a client reports the date format of datepicker is incorrect.

By looking into that, I found there literally has three different issues/things we need to understand, before we can make the datepicker formatting work.

First issue
Parameters for datepicker called "DateFormat" is always overwritten when it gets initial. For example, the parameter the client configured in the form is <DateFormat>dd-MM-yyyy</DateFormat>. and then it gets overwritten as "yy-mm-dd".

Second issue
It's related to the parameters, take the above example that <DateFormat>dd-MM-yyyy</DateFormat>. Initially I thought dd-MM-yyyyis the format. However, it is not. It is the Item Name of a Date Format item in sitecore. the the format that datepicker applied is the value of that Date Format Item.

Third issue
Due to the fact that the datepicker is using JQuey datepicker, the date format is different from the standard date and time format defined by Microsoft. the Jquery datepicker format is as below

$.datepicker.formatDate( format, date, options )

Format a date into a string value with a specified format.

The format can be combinations of the following:

  • d - day of month (no leading zero)
  • dd - day of month (two digit)
  • o - day of the year (no leading zeros)
  • oo - day of the year (three digit)
  • D - day name short
  • DD - day name long
  • m - month of year (no leading zero)
  • mm - month of year (two digit)
  • M - month name short
  • MM - month name long
  • y - year (two digit)
  • yy - year (four digit)
  • @ - Unix timestamp (ms since 01/01/1970)
  • ! - Windows ticks (100ns since 01/01/0001)
  • '...' - literal text
  • '' - single quote
  • anything else - literal text

So, to walk around the issue that the client is having. I just update the value of the Date Format Item (as explained above, it will be always "yy-mm-dd" item) with the Jquery date format. i.e. d-mm-yy

1. https://api.jqueryui.com/datepicker/