search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

How to change the data format in daypilot shechduler control

Asked by J Sampath Kumar
7 years ago.

I want to bind the data in which date format is ("dd/MM/yy") but day pilot is considering (MM/dd/yy)

how can I change it.

Answer posted by Dan Letecky [DayPilot]
7 years ago.

DayPilot is loading the event start and end dates using a code similar to this:

            string strStart = DataBinder.GetPropertyValue(dataItem, DataStartField, null);
            if (!DateTime.TryParse(strStart, out start))
            {
                throw new FormatException(String.Format("Unable to convert '{0}' (from DataStartField column) to DateTime.", strStart));
            }

This means the field value is read as string and then parsed. If the value is DateTime this works without problem because the same format and culture is used.

However, if you supply a DateTime string that is not formatted in accordance with the current culture it will not be parsed properly. The solution is to supply a DateTime object (in DataStartField and DataEndField) or to adjust the culture of the current thread (use <globalization> in web.config or System.Threading.Thread.CurrentThread.CurrentCulture in the code behind).

This question is more than 3 months old and has been closed. Please create a new question if you have anything to add.