Your search did not match any results.

Date Range Box - Formatting

Use our DateRangeBox displayFormat property to change date display format as requirements dictate.

Backend API
<div class="dx-fieldset"> <div class="dx-field"> <div class="dx-field-label">Locale-dependent format</div> <div class="dx-field-value"> @(Html.DevExtreme().DateRangeBox() .StartDatePlaceholder("12/31/2018") .EndDatePlaceholder("12/31/2018") .ShowClearButton(true) .UseMaskBehavior(true) .OpenOnFieldClick(false) ) </div> </div> <div class="dx-field"> <div class="dx-field-label">Built-in predefined format</div> <div class="dx-field-value"> @(Html.DevExtreme().DateRangeBox() .DisplayFormat(Format.ShortDate) .StartDate(new JS("startDate")) .EndDate(new JS("endDate")) .ShowClearButton(true) .UseMaskBehavior(true) .OpenOnFieldClick(false) ) </div> </div> <div class="dx-field"> <div class="dx-field-label">Locale Data Markup Language (LDML) pattern</div> <div class="dx-field-value"> @(Html.DevExtreme().DateRangeBox() .DisplayFormat("EEEE, d of MMM, yyyy") .StartDate(new JS("startDate")) .EndDate(new JS("endDate")) .ShowClearButton(true) .UseMaskBehavior(true) .OpenOnFieldClick(false) ) </div> </div> <div class="dx-field"> <div class="dx-field-label">Format with literal characters</div> <div class="dx-field-value"> @(Html.DevExtreme().DateRangeBox() .DisplayFormat("'Year': yyyy, 'Month': MMM, 'Day': d") .StartDate(new JS("startDate")) .EndDate(new JS("endDate")) .ShowClearButton(true) .UseMaskBehavior(true) .OpenOnFieldClick(false) ) </div> </div> </div> <script> var msInDay = 1000 * 60 * 60 * 24; var now = new Date(); var startDate = new Date(now.getTime() - msInDay * 3); var endDate = new Date(now.getTime() + msInDay * 3); </script>
using System.Web.Mvc; namespace DevExtreme.MVC.Demos.Controllers { public class DateRangeBoxController : Controller { public ActionResult Formatting() { return View(); } } }
.demo-container { height: 610px; } .dx-fieldset { min-height: 500px; } .dx-field { padding: 8px; }

This demo illustrates the following:

  • Locale-dependent format
    DateRangeBox formats date range values based upon the specified locale. You do not need to define a format with the displayFormat property. For more information, refer to the following help topic: Localize Dates, Numbers, and Currencies.

  • Built-in predefined formats
    DevExtreme allows you to apply various predefined formats. You can specify simple strings or shortcuts that define widely used date formats instead of complex expressions. This demo illustrates how to display dates using the "shortdate" format.

  • Locale Data Markup Language (LDML) pattern To define a custom date format string, use the LDML pattern. In this demo, the displayFormat property is set to "EEEE, d of MMM, yyyy". This expression displays week day, day number, month and year. The input field displays the formatted value. For additional information on supported format characters, refer to the following help topic: Custom Format String.

  • Add literal characters
    You can specify the displayFormat property as a string with literal and Locale Data Markup Language characters. You should wrap characters that are not part of the LDML pattern within quotation marks - otherwise, they may be interpreted as wildcards. In this demo, if you specify the word "Year" without quotation marks, the letter "a" is interpreted as an "AM/PM" placeholder.

To ensure that input values match displayFormat, you can apply an input mask to our DateRangeBox (set the control’s useMaskBehavior property to true).

For additional formatting-related information, please refer to the following help topic: Value Formatting.