We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to set the date format for DatePicker component

Platform: JavaScript - EJ 2 |
Control: DatePicker |
Published Date: June 4, 2018 |
Last Revised Date: June 5, 2018

 

The purpose of formatting is to convert a Date object to display the date in a specific string format is to simplify the date representation. Each culture has a standard format to display the date value. For example, in English culture, the month is displayed first followed by date and year, and in some other cultures, the date is displayed first followed by month and year. Hence, this may become uncertain to differentiate between the month and date in the displayed value. To overcome this, a custom format can be specified to display the date format as explained as follows.

By default, in the DatePicker component, the date format is culture specific which is convenient for the users in the specific culture. Customize the format to display the date in any required format can be defined by using the format property of the DatePicker component.

Refer to the following code example to set the format value of the DatePicker component.

 

var datepicker = new ej.calendars.DatePicker({

        placeholder: 'Choose a date',

        format: 'dd-MMM-yyyy',

    });

    datepicker.appendTo('#element');

 

The previous code displays the date as follows.

 

Refer to the following sample link to check the functionality of format API of the DatePicker component.

Sample link:

https://ej2.syncfusion.com/16.1.37/demos/#/material/datepicker/date-format.html

 

 

ADD COMMENT
You must log in to leave a comment
Comments
Gregory Perozzo
Dec 06, 2018

Thank you very much

Reply
Ali
Jan 12, 2019

add

Reply

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon