Handling Dates with JavaScript Calendars Package | Syncfusion Blogs
Live Chat Icon For mobile
Live Chat Icon
Popular Categories.NET  (182).NET Core  (27).NET MAUI  (233)Angular  (117)ASP.NET  (49)ASP.NET Core  (81)ASP.NET MVC  (87)Azure  (42)Black Friday Deal  (1)Blazor  (244)BoldSign  (15)DocIO  (24)Essential JS 2  (109)Essential Studio  (200)File Formats  (74)Flutter  (140)JavaScript  (227)Microsoft  (121)PDF  (86)Python  (1)React  (107)Streamlit  (1)Succinctly series  (131)Syncfusion  (991)TypeScript  (33)Uno Platform  (3)UWP  (3)Vue  (46)Webinar  (53)Windows Forms  (59)WinUI  (72)Word  (9)WPF  (165)Xamarin  (159)XlsIO  (38)Other CategoriesBarcode  (5)BI  (29)Bold BI  (8)Bold Reports  (2)Build conference  (11)Business intelligence  (55)Button  (4)C#  (164)Chart  (154)Chart of the week  (62)Cloud  (16)Company  (440)Dashboard  (8)Data Science  (3)Data Validation  (8)DataGrid  (74)Development  (694)Doc  (8)DockingManager  (1)eBook  (99)Enterprise  (22)Entity Framework  (7)Essential Tools  (13)Excel  (43)Extensions  (31)File Manager  (8)Gantt  (23)Gauge  (12)Git  (5)Grid  (31)HTML  (13)Installer  (2)Knockout  (2)Language  (1)LINQPad  (1)Linux  (2)M-Commerce  (1)Metro Studio  (11)Mobile  (530)Mobile MVC  (9)OLAP server  (2)Open source  (1)Orubase  (12)Partners  (21)PDF viewer  (48)Performance  (13)PHP  (2)PivotGrid  (5)Predictive Analytics  (6)Report Server  (3)Reporting  (8)Reporting / Back Office  (9)Rich Text Editor  (12)Road Map  (12)Scheduler  (54)Security  (5)SfDataGrid  (9)Silverlight  (21)Sneak Peek  (32)Solution Services  (4)Spreadsheet  (11)SQL  (15)Stock Chart  (1)Surface  (4)Tablets  (5)Theme  (12)Tips and Tricks  (112)UI  (426)Uncategorized  (68)Unix  (2)User interface  (68)Visual State Manager  (2)Visual Studio  (31)Visual Studio Code  (19)Web  (648)What's new  (354)Windows 8  (19)Windows App  (2)Windows Phone  (15)Windows Phone 7  (9)WinRT  (26)

Handling Dates with JavaScript Calendars Package

This blog is intended to give you a clear understanding of the best way to utilize the Essential JS 2 calendars package to choose the best-suited UI components to handle date-time values in your modern web apps.

From the package name itself, you knew that the package was going to have a calendar component. Yes, of course you’re right, but this package not only holds the calendar, it has a huge set of UI components (date picker, time picker, date-time picker, and date-range picker) to handle the date values as a single selection or range of selections in web applications.

The core intention of the calendars package is to cover all the possibilities of date-time value handling in the web with the most flexible and best-suited UI tools. They should help user interaction be smoother in applications and reduce the job of developers handling date-value codes in the development process.

As I mentioned earlier, the calendars package includes the following set of components:

What has been considered in developing these components?

UX design of components in calendars package

What will initially cause more users to choose one application over another? Most of them will go with the simplest and best UX design of the application. So, the best-designed application requires the best-designed subset of UI tools.

Here the components in the calendars package are made with a simple and excellent UX design that fits into our multiple-device world.

You can see in the following screen shot a component’s UX design covering all the required use cases for selecting a date and time as quickly as possible.


  1. Header text specifies the name of the current month that is displayed in the calendar table.
  2. Up and down arrows to navigate the previous and next months in calendar.
  3. Header of the days of the week.
  4. Week number of the year.
  5. Dates in calendar table.
  6. Today button in footer to quickly pick today’s date.

The header text of the calendar is clickable to drill down from month to year as well as year to decade and vice versa. It gives a nice experience to end users for selecting far off dates in an easy, fast way. Let’s see the UX of a drilled-down calendar in month view.

month calendar

The drill-down or up options not only give users an easy way to select a date, they also allow you to change the calendar so that only the month or year can be selected as values. So, you can use the calendar to act as a month or year picker.
This is a cool way you can make use of a single component as a date, month, or year picker based on your application choice. Following, you can see the year view of calendar.
year calendar
As we have seen the calendar design, now let’s see the date picker UX design that covers both desktop and mobile devices.
  1. Text box in which to enter a date value.
  2. Cross icon allows clearing of the value in the text box.
  3. Drop-down calendar icon to pop up the calendar and pick a date.
  4. Header that displays the name of the month, year, or decade shown in the calendar table.
  5. Up and down arrows to navigate the previous and next months in the calendar.
  6. Header with days of the week.
  7. Selected date.
  8. Week number of the year.
  9. All the dates in the calendar table.
  10. Today button in footer to pick today’s date in the calendar.
You may think there’s no major difference between calendar and date picker, but there’s a difference. Date picker is an editable input form component and only takes HTML input for rendering, whereas calendar can be used in form or anywhere as inline and takes all elements for rendering.
In mobile devices, the date picker is more adaptive, as seen in the following screenshot, and gives a better user experience.
Here the calendar pop-up is placed at the center of the device for easy interaction.Well, now let’s see the simple time picker component that pops out of the time list to select the time value.
  1. Text box in which to enter the time value.
  2. Cross icon allows clearing of the value in the text box.
  3. Drop-down time icon to pop up the time list and pick the time.
  4. Default scroller to scroll and pick the time easily.
  5. Selected time value highlighted in list.
In mobile devices, the pop-up comes over the text box so that you can easily pick the time value from pop-up time list.
Next is the date-time picker. The UX design of the date-time picker component is a combination of both the date picker and time picker. So only the text box holds the two icons, date and time, to pop out the calendar and select a date and time list from which to select the time.
Finally, we are going to see the UX of date-range picker. This component is for selecting two dates as the start and end of a range. It presents nice user interaction on the desktop by showing two consecutive months in parallel, as shown in the following image.
  1. Text box in which to enter the start and end date values.
  2. Drop-down range calendar icon to pop up the date-range calendar.
  3. Represents the selected start and end month.
  4. Represents the number of days in the selected date range.
  5. Previous and next month navigation pointer.
  6. Header text representing the name of the current month shown.
  7. Selected start date in left-side calendar.
  8. Selected end date in right-side calendar.
  9. Apply button to update the selected date-range value.
  10. Cancel button to cancel the selection of a date range.
But if the same UX design is used for mobile, then it’s definitely not going to have the best user interaction for choosing start and end dates. Well, it won’t happen: the UX design of the component switches automatically with the devices or minimal resolution to bring the best user-friendly UI, as shown in the following.
  1. Toggle button to change the start date and end date selection.
  2. Represents the number of days in the selected date range.
  3. Header text with the name of the month being shown.
  4. Selected start date.
  5. Selected end date.
  6. Today’s date is highlighted.
  7. Apply button to update the selected date-range value.
  8. Cancel button to cancel the selection of a date range.
That design brings the Date-range picker as more adaptive and can show a single calendar for start and end date selection. Another preferred use case in this component is a predefined set of ranges from which to make a quick selection. Here, the presets are presented as a drop-down list that works in all devices as shown in the following.
preset range

From the UX design, it’s clear that these components are more user friendly in all devices because they cover all required use cases.

Functionalities covered in components

Not only do these components provide better user experience through UX design, they also cover all functionalities in the basis of the 80:20 rule with flexible options that will fulfill all business needs in modern applications. Here are these features:

Month or year selection—In calendar and date picker, these provide flexible options to select only the month or year as a date value.

Date range—Restricts the range of dates that can be selected.

Globalization—Supports globalization (internationalization and localization) to translate the names of months, days, and the today button text to any supported language.

First day of week—Change the first day of weeks in every month.

Disabled dates—Any date can be disabled to prevent selection.

Customization—You have complete control over the appearance of the date components.

Highlight weekends—Highlight every weekend in a month.

Week number—Show the week number of selected dates by enabling the week number options.

Formatting—Input values can be set to be custom formatted apart from the default culture-specific date format.

Validation—Allows only valid values to be entered in input by validating that values are not invalid, disabled, or out-of-min or out-of-max of the date range. The disabled and out-of-date-range values are set to be in a disabled state that prevents the end user from selecting them.

Predefined ranges—In date-range picker, define a preset of ranges to allow end users to select a frequently used date range.

When to use which component

Calendar acts as an inline component and is best suited when you want to visualize data on specific date.

Date Picker is a form component used to get or set a date value, so it’s best suited when only using a date as a value.

Time Picker is a form component used to get or set a time value, so it’s best suited when only using a time as a value.

Date-Time Picker is a form component used to get or set a date-time value, so it’s best suited when using a date as well as a time value.

Date-Range Picker is a form component used to get or set start and end date values, so it’s best suited when using a range of dates.


I hope now you understand the Syncfusion JavaScript calendars package and its available components, including their usage and when they best suit your applications. Stay tuned for other blogs about our Essential JS 2 components and their features.

Try our date-time components by downloading from the free trial or GitHub. Feel free to have a look at our online samples and documentation to explore other available options. If you have any questions or require clarification, please let us know in the comments section below. You can also contact us through our support forum or Direct-Trac. We are always happy to assist you!

If you like this blog post, we think you’ll also like the following free e-books:



Share this post:

Comments (4)

Hello! Is it possible to have users select time on the date range picker? And would that be mobile friendly as well?

Hi Faith,

At present there’s no option to select the time on date range picker. We have already logged a feature request on this requirement and sure it will be mobile friendly on selecting the date and time range. You could have track the feature status from this feedback https://www.syncfusion.com/feedback/5760/new-datetimerangepicker-control.

Also there’s an option to enter the date time range value in date range picker without UI interaction on selecting time, to do so please refer this sample https://ej2.syncfusion.com/demos/#/material/daterangepicker/date-format.html.

I’m using the date picker control and the situation is as follows:

In an application for booking appointments in a medical clinic, , I need to block a period of consecutive dates (for example, when a doctor is on vacations), showing an icon, so that the user understands why, in that period, the appointments are not possible for that doctor. Is this possible? Can you show me how (with code, if possible)? Thanks

Hello Fausto,

Yes. It is possible to show an icon for a specified date or a range of dates. In RenderDayCell event, you can get the details of the cell which is currently being rendered. With the help of this event callback, you can add the icon to the respective calendar date cell. Also you can set the property isDisabled of RenderDayCellEventArgs as true to block a certain date gets selected. Please find the code snippet and sampe below. In this sample we have added icons to the dates which are in the range between 10 and 20.

function customDates(args: RenderDayCellEventArgs): void {
/*Date need to be customized*/
if (args.date.getDate() >= 10 && args.date.getDate() <= 20) {
// To disable the current cell
args.isDisabled = true;
let span: HTMLElement;
span = document.createElement("span");
span.setAttribute("class", "fa fa-exclamation");
"Doctor is in Vacation !"

/*Override the default pointer events css from none to auto to display tooltip when hover*/
.e-calendar .e-content td.e-disabled {
pointer-events: auto;
/*When active set none to prevent click in disabled element*/
.e-calendar .e-content td.e-disabled:active {
pointer-events: none;

Sample Link : https://stackblitz.com/edit/special-dates

Saravanan G

Comments are closed.

Popular Now

Be the first to get updates

Subscribe RSS feed

Be the first to get updates

Subscribe RSS feed