---
updatedAt: 2025-07-15T08:37:19.000Z
agentTools:
  projectIndex: https://docs.appery.io/llms.txt
---

# Ionic Date and Time Input Sample App

Sample app demonstrating Date and Time Input in Ionic

# Introduction

In this sample app, we will demonstrate several ways of entering date and time values in an [Appery.io](https://appery.io/) app:

<HTMLBlock>{`
<div style="border-width:1px;border-style:solid;width:377px;border-color:grey;">
      <iframe src="https://datetime.app.appery.io/#/screen1/#/homepage" seamless="seamless" frameborder="0" style="overflow:hidden;overflow-x:hidden;overflow-y:hidden;height:667px;width:375px;top:0px;left:0px;right:0px;bottom:0px"></iframe>
</div>


<style></style>
`}</HTMLBlock>

First, you will learn how to implement single date and time input, then we will move on to more complicated cases: multiple dates and date ranges input types.

# Creating App

You can select how you would like to get the app working under your [Appery.io account](https://docs.appery.io/docs/account):

1. [Download the app backup](#downloads-and-resources) with further installing it (the backup can be securely saved for further use);
2. [Create the app from our template](#creating-app-from-template) with one click (the easiest and quickest option: you will get the working app in a matter of moments)
3. [Create the app by yourself](#creating-new-app) using our step-by-step illustrated instructions (more time-consuming but highly educating option that will help in mastering work with [Appery.io](https://appery.io)).

## Downloads and Resources

You can try the app yourself by recreating it from the [backup](https://appery.io/wp-content/uploads/tutorial-ionic5-datetime-input-app.zip).

To restore the app from the backup, follow these steps:

1. Download the app backup file.
2. Click **From backup** and select the project backup file on your drive.
3. Type in the app name and click **Create**.

## Creating App from Template

> 👍 NEW: One-Click Template Installation!
>
> You can now enjoy the one-click-away option of installing the template app: simply click the button below and in a moment, your app is ready to start! There’s no need to go to the **Create new app** dialog or download the template backup with further installing it!

<HTMLBlock>{`
<html><head><style>
    .btn:link,
    .btn:visited {
        text-decoration: none;
        padding: 15px 40px;
        display: inline-block;
        border-radius: 100px;
        transition: all .2s;
        position: relative;
        color: #fff;
    }

    .btn:hover {
        transform: translateY(-3px);
        box-shadow: 0 10px 20px rgba(0, 0, 0, .2);
    }

    .btn:active {
        transform: translateY(-1px);
        box-shadow: 0 5px 10px rgba(0, 0, 0, .2);
    }

    .btn-green {
        background-color: #09B300;
        color: #fff;
    }

    .btn::after {
        content: "";
        display: inline-block;
        height: 100%;
        width: 100%;
        border-radius: 100px;
        position: absolute;
        top: 0;
        left: 0;
        z-index: -1;
        transition: all .4s;
    }

    .btn-green::after {
        background-color: #55c57a;
    }

    .btn:hover::after {
        transform: scaleX(1.4) scaleY(1.6);
        opacity: 0;
    }
</style>
 </head><body><a href="https://appery.io/app/projects/action/create-from-template?name=DateTimeApp&guid=b6a3700f-718e-4708-8fe9-049a37da346d" class="btn btn-green" target="_blank">Create in Appery.io</a></body></html>
`}</HTMLBlock>

But if you are interested in the app details, please check out the steps below.

## Creating New App

1. Navigate to the [Appery.io dashboard](https://appery.io/app/projects). Here, from the **[Apps](https://appery.io/app/projects)** tab, click **[Create new app](https://docs.appery.io/docs/1-creating-an-app-ui-palette#creating-new-app)**.
2. Select **[Blank](https://docs.appery.io/docs/ionic-5-app-templates#ionic-5-blank)** as a template. Name it, for example, ***Ionic DateTimeApp*** and confirm by clicking **Create**.\
   In a moment, you will find yourself inside Appery.io **[App Builder](https://docs.appery.io/docs/apperyio-app-builder-overview)**.
3. Go to the [**Project** tab](https://docs.appery.io/docs/apperyio-app-builder-overview#project-tab) on the left and unfold the **Pages** folder to see the default app pages (screens): **[app](https://docs.appery.io/docs/2-creating-an-app-ui-pages-and-tabs#index-screen)** and **[Screen1](https://docs.appery.io/docs/2-creating-an-app-ui-pages-and-tabs#pages-screens)**.
4. Now, create six more pages by clicking **CREATE NEW > Page** that will be later defined to feature different cases of inputting date and time. Name them to **CustomPicker**, **CustomPickerModal**, **DateModal**, **Datetime**, **Input**, and **ModalMode** accordingly:

<Image align="center" className="border" width="smart" border={true} src="https://files.readme.io/4c6dfee-Screenshot_7.png" />

## Defining *Main* Page

1. First of all, rename the **Screen1** page to **Main**:

<Image align="center" className="border" width="smart" border={true} src="https://files.readme.io/a9187c3-Untitled.png" />

and under the page **[PROPERTIES](https://docs.appery.io/docs/1-creating-an-app-ui-palette#properties-overview)** panel, set the **Page Footer** property to ***False***.

2. Then, select its **[Toolbar](https://docs.appery.io/docs/ionic-5-ui-components-properties#toolbar)** component and change its **Color** property to ***tertiary*** and its **Mode** property to ***iOS***; then switch to the **[ToolbarTitle](https://docs.appery.io/docs/ionic-5-ui-components-properties#toolbar-title)** component and set it's **Text** = ***📅 Demo app: date and time input***:

<Image align="center" className="border" border={true} src="https://files.readme.io/d1c9ffe-Screenshot_10.png" />

3. Now, drag five **[Card](https://docs.appery.io/docs/ionic-5-ui-components-properties#card)** components and drop them to the **[Content](https://docs.appery.io/docs/2-creating-an-app-ui-pages-and-tabs#content-component)** area. Five cards will be created each nesting one default **[Card Item](https://docs.appery.io/docs/ionic-5-ui-components-properties#card-ltem)** with a **[Card Item Title](https://docs.appery.io/docs/ionic-5-ui-components-properties#card-ltem-title)**.
4. Under the page **[PROPERTIES](https://docs.appery.io/docs/1-creating-an-app-ui-palette#properties-overview)** panel, one by one, select every card and set their **Route Name** parameters as described below:

* for **Card1**: ***Input***
* for **Card2**: ***Datetime***
* for **Card3**: ***CustomPicker***
* for **Card4**: ***CustomPickerModal***
* for **Card5**: ***ModalMode***:

<Image align="center" className="border" border={true} src="https://files.readme.io/d81a84e-Screenshot_11.png" />

5. Also, select every **[Card Item](https://docs.appery.io/docs/ionic-5-ui-components-properties#card-ltem)** one by one and define their corresponding **Text** properties as follows:

* for **Card1**: ***Using a simple Appery Input component***
* for **Card2**: ***Using Ionic Datetime component***
* for **Card3**: ***Using ion2-calendar module for single, multi, or range date picking***
* for **Card4**: ***Using Appery Modal screen to select dates***
* for **Card5**: ***Using ion2-calendar's Modal mode***.\
  Additionally, set each item's **Mode** property to ***iOS***.

6. Finally, select every **[Card Item Title](https://docs.appery.io/docs/ionic-5-ui-components-properties#card-ltem-title)** one by one and define their **Title Text** properties as follows:

* for **Card1**: ***1. Input component***
* for **Card2**: ***2. Ionic Datetime***
* for **Card3**: ***3. Custom picker***
* for **Card4**: ***4. Custom picker in Modal screen***
* for **Card5**: ***5. Custom picker in Modal mode***.

Also, set the **Mode** property of each to ***iOS***.

7. To finish, add the following code to the style code editor under the **[SCSS](https://docs.appery.io/docs/apperyio-visual-builder#scss-panel)** panel:

```css
.hidden {
    display: none;
}
```

<Image align="center" className="border" border={true} src="https://files.readme.io/d81c953-Screenshot_13.png" />

We are done with the **Main** page. To see how it should look like on the preview, click the **TEST** button in the **[App Builder Toolbar](https://docs.appery.io/docs/apperyio-visual-builder#toolbar)**:

<Image align="center" className="border" width="smart" border={true} src="https://files.readme.io/927da74-Screenshot_35.png" />

# Using Appery.io *Input* Component

For some reason, you may need the ability to enter dates from the keyboard on the desktop. This can be implemented using the **[Input](https://docs.appery.io/docs/ionic-5-ui-components-properties#input)** component with its **Type** attribute set to ***Date*** or ***Time***. It creates an input field that allows entering a date or a time value, either with a text box that validates the input or a special date picker interface. The date value will be formatted as `yyyy-mm-dd`.

1. So, let's go to the **Input** page to add this functionality.
2. Under the **[PROPERTIES](https://docs.appery.io/docs/1-creating-an-app-ui-palette#properties-overview)** panel, set the **Page Footer** property to ***False***, then select its **[Toolbar](https://docs.appery.io/docs/ionic-5-ui-components-properties#toolbar)** component and set its **Color** property to ***tertiary*** and its **Mode** property to ***iOS***; then switch to the **[ToolbarTitle](https://docs.appery.io/docs/ionic-5-ui-components-properties#toolbar-title)** component and change it's **Text** property to ***Using Input component***.
3. Then, from the **[PALETTE](https://docs.appery.io/docs/1-creating-an-app-ui-palette#ui-components-palette-overview)** panel, drag & drop the **[Button](https://docs.appery.io/docs/ionic-5-ui-components-properties#button)** component to the **[Toolbar Buttons](https://docs.appery.io/docs/ionic-5-ui-components-properties#toolbar-buttons)** area and set its **Component type** property to ***[Ionic Back Button](https://docs.appery.io/docs/ionic-5-ui-components-properties#ionic-back-button)***.
4. Drag two **[Grid](https://docs.appery.io/docs/ionic-5-ui-components-properties#grid)** components and drop them to the **[Content](https://docs.appery.io/docs/2-creating-an-app-ui-pages-and-tabs#content-component)** area.\
   Two grids will be created each nesting one default **[Grid Row](https://docs.appery.io/docs/ionic-5-ui-components-properties#grid-row)** with two child **[Grid Cell](https://docs.appery.io/docs/ionic-5-ui-components-properties#grid-cell)** components.
5. For each row, select the right **[Grid Cell](https://docs.appery.io/docs/ionic-5-ui-components-properties#grid-cell)** and remove them from by using the **[Context menu](https://docs.appery.io/docs/1-creating-an-app-ui-palette#context-menu-overview)** or simply click the red **cross** icon:

<Image align="center" className="border" width="smart" border={true} src="https://files.readme.io/aa554f5-Screenshot_17.png" />

6. Now, let's define the first **[Grid Row](https://docs.appery.io/docs/ionic-5-ui-components-properties#grid-row)**:

* Drag the **[Text](https://docs.appery.io/docs/ionic-5-ui-components-properties#text)** component  and drop it to the **[Grid Cell](https://docs.appery.io/docs/ionic-5-ui-components-properties#grid-cell)**, replace its default **Text** property with ***Pick date and time:*** and set its **Container** property as ***h3***:

<Image align="center" className="border" border={true} src="https://files.readme.io/7428bce-Screenshot_18.png" />

After that, switch to the component's **Styles** tab and set the **Class** property to ***ion-margin-horizontal***:

<Image align="center" className="border" border={true} src="https://files.readme.io/6b97323-Screenshot_40.png" />

* Drag two **[Input](https://docs.appery.io/docs/ionic-5-ui-components-properties#input)** components and drop them below the text and define their properties like this:
* for the first input component:
  * **Value** = ***2022-01-01***
  * **Placeholder** = ***Select date***
  * **Type** = ***Date***
  * **Label > Text** = ***Date***
  * **Label > Position** = ***Stacked***
  * **Label > Mode** = ***iOS***
  * **\[(ngModel)]** = ***date***:
* for the second input component:
  * **Value** = ***10:30***
  * **Placeholder** = ***Select time***
  * **Type** = ***Time***
  * **Label > Text** = ***Time***
  * **Label > Position** = ***Stacked***
  * **Label > Mode** = ***iOS***
  * **\[(ngModel)]** = ***time***:

<Image align="center" className="border" width="smart" border={true} src="https://files.readme.io/f0e621e-Screenshot_19.png" />

7. Move to the second **[Grid](https://docs.appery.io/docs/ionic-5-ui-components-properties#grid)** now and define its **[Grid Row](https://docs.appery.io/docs/ionic-5-ui-components-properties#grid-row)**.

* First, drag another **[Text](https://docs.appery.io/docs/ionic-5-ui-components-properties#text)** component and drop it to the **[Grid Cell](https://docs.appery.io/docs/ionic-5-ui-components-properties#grid-cell)** and set its **Text** property to ***Selected values:*** and its **Container** property as ***h3***. Switch to the component's **Styles** tab and set the **Class** property to ***ion-margin-horizontal***.
* Now, drop the **[List](https://docs.appery.io/docs/ionic-5-ui-components-properties#list)** component below the text. A list with two default **[List item](https://docs.appery.io/docs/ionic-5-ui-components-properties#list-item)**&#x73; each having a child **[Item Label](https://docs.appery.io/docs/ionic-5-ui-components-properties#item-label)** component will be created. Set the list **Mode** property to ***iOS***.
* Go to the first **[Item Label](https://docs.appery.io/docs/ionic-5-ui-components-properties#item-label)** and define its **Text** property as ***\{\{ date ? (date | date) : 'not selected'}}***.
* Then, define the **Text** property of the second **[Item Label](https://docs.appery.io/docs/ionic-5-ui-components-properties#item-label)** to ***\{\{ time ? time : 'not selected'}}***.
* Finally, add per one **[Icon](https://docs.appery.io/docs/ionic-5-ui-components-properties#icon)** component to both **[List item](https://docs.appery.io/docs/ionic-5-ui-components-properties#list-item)** and define their properties accordingly:
* **Name**= ***calendar*** (for **ListItem1**)/***time*** (for **ListItem2**)
* **Color** = ***tertiary***
* **Slot** = ***Start***:

<Image align="center" className="border" width="smart" border={true} src="https://files.readme.io/1ad8c01-Screenshot_20.png" />

8. Save the changes and switch to the **[CODE](https://docs.appery.io/docs/apperyio-visual-builder#code-panel)** panel.\
   Here, in the **Variables** section, create 2 variables, both of **String** type: `date` and `time`:

<Image align="center" className="border" border={true} src="https://files.readme.io/a52c517-Screenshot_39.png" />

> 🚧 Placeholder Attribute
>
> Note that the **Placeholder** attribute doesn't work with Inputs of **Date** and **Time** type. You can set the default input **Value** instead.
>
> If you still need a placeholder in your control, please try the [Datetime](https://docs.appery.io/docs/ionic-5-ui-components-properties#datetime) component.

That’s it, you can now test the pickers in the preview. When you click the date input field, the native datepicker dialog will appear. Also, on the desktop, you can type the date manually. The appearance of the picker may vary depending on the browser and OS:

<Image align="center" className="border" width="smart" border={true} src="https://files.readme.io/c2bc6df-1.gif" />

> 🚧 Desktop Safari Support
>
> Also note that Safari desktop browser does not include a native datepicker (although it does for iOS). Instead, a regular text input will be shown.
>
> Useful link for tracking browser support: <http://caniuse.com/#feat=input-datetime>

# Using Ionic *Datetime* Component

The simplest way is to use the [Datetime](https://ionicframework.com/docs/api/datetime) component from Ionic. It displays values in two places: in the component itself and in the picker interface that is presented at the bottom of the screen. This picker interface looks the same on both platforms and in the browser.

1. Open the **Datetime** page and under the page **[PROPERTIES](https://docs.appery.io/docs/apperyio-visual-builder#properties-overview)** panel, set the **Page Footer** property to ***False***.
2. Then, select its **[Toolbar](https://docs.appery.io/docs/ionic-5-ui-components-properties#toolbar)** component and set its **Color** property to ***tertiary*** and its **Mode** property to ***iOS***; then switch to the **[ToolbarTitle](https://docs.appery.io/docs/ionic-5-ui-components-properties#toolbar-title)** component and change it's **Text** property to ***Using Datetime component***.
3. From the **[PALETTE](https://docs.appery.io/docs/1-creating-an-app-ui-palette#ui-components-palette-overview)**, drag and drop the **[Button](https://docs.appery.io/docs/ionic-5-ui-components-properties#button)** component to the **[Toolbar buttons](https://docs.appery.io/docs/ionic-5-ui-components-properties#toolbar-buttons)** area and set its **Component type** property to  to ***[Ionic Back Button](https://docs.appery.io/docs/ionic-5-ui-components-properties#ionic-back-button)***.
4. Now, drag two **[Grid](https://docs.appery.io/docs/ionic-5-ui-components-properties#grid)** components and drop them to the **[Content](https://docs.appery.io/docs/2-creating-an-app-ui-pages-and-tabs#content-component)** area.\
   Two grids will be created each nesting one default **[Grid Row](https://docs.appery.io/docs/ionic-5-ui-components-properties#grid-row)** with two child **[Grid Cell](https://docs.appery.io/docs/ionic-5-ui-components-properties#grid-cell)** components.
5. For each row, select the right **[Grid Cell](https://docs.appery.io/docs/ionic-5-ui-components-properties#grid-cell)** and remove them by using the **[Context menu](https://docs.appery.io/docs/1-creating-an-app-ui-palette#context-menu-overview)** or simply click the red **cross** icon.
6. Now, let's define the first **[Grid Row](https://docs.appery.io/docs/ionic-5-ui-components-properties#grid-row)**:

* Drag the **[Text](https://docs.appery.io/docs/ionic-5-ui-components-properties#text)** component and drop it to **Grid Cell1**; then set its **Text** property to ***Pick date and time:*** and its **Container** property as ***h3***. After that, switch to the component's **Styles** tab and set the **Class** property to ***ion-margin-horizontal***.
* Now, drag two **[Datetime](https://docs.appery.io/docs/ionic-5-ui-components-properties#datetime)** components and drop them below the text.\
  Define the first as follows:
* **Placeholder** = ***Select date***
* **Label > Text** = ***Date***
* **Label > Position** = ***Stacked***
* **\[(ngModel)]** = ***date*** .\
  Then, select the second **[Datetime](https://docs.appery.io/docs/ionic-5-ui-components-properties#datetime)** component and define it as follows:
* **Placeholder** = ***Select time***
* **Display Format** = ***hh:mm A***
* **Label > Text** = ***Time***
* **Label > Position** = ***Stacked***
* **\[(ngModel)]** = ***time*** :

<Image align="center" className="border" border={true} src="https://files.readme.io/3207f23-Screenshot_22.png" />

8. Move to the second **[Grid](https://docs.appery.io/docs/ionic-5-ui-components-properties#grid)** and define its **[Grid Row](https://docs.appery.io/docs/ionic-5-ui-components-properties#grid-row)**:

* First, drag another **[Text](https://docs.appery.io/docs/ionic-5-ui-components-properties#text)** component and drop it to the **[Grid Cell](https://docs.appery.io/docs/ionic-5-ui-components-properties#grid-cell)**; then set its **Text** property to ***Selected values:*** and its **Container** property as ***h3***. After that, switch to the component's **Styles** tab and set the **Class** property to ***ion-margin-horizontal***.
* Now, drop the **[List](https://docs.appery.io/docs/ionic-5-ui-components-properties#list)** component below the text. A list with two default **[List item](https://docs.appery.io/docs/ionic-5-ui-components-properties#list-item)**&#x73; each having a child **[Item Label](https://docs.appery.io/docs/ionic-5-ui-components-properties#item-label)** component will be created:
  * Define the **Text** property of the first **[Item Label](https://docs.appery.io/docs/ionic-5-ui-components-properties#item-label)** to ***\{\{ date ? (date | date) : 'not selected'}}***
  * Define the **Text** property of the second **[Item Label](https://docs.appery.io/docs/ionic-5-ui-components-properties#item-label)** to ***\{\{ time ? ( time | date: 'shortTime' ) : 'not selected'}}***:

<Image align="center" className="border" border={true} src="https://files.readme.io/ce1cd19-Screenshot_23.png" />

* To finish, add per one **[Icon](https://docs.appery.io/docs/ionic-5-ui-components-properties#icon)** component to both **[List item](https://docs.appery.io/docs/ionic-5-ui-components-properties#list-item)**&#x73; and define their properties accordingly:
* **Name**= ***calendar*** (for **ListItem1**)/***time*** (for **ListItem2**)
* **Color** = ***tertiary***
* **Slot** = ***Start***.

> 📘
>
> For the **Name** property, click the **Default icon** button to select the icon you need:

<Image align="center" className="border" border={true} src="https://files.readme.io/d08605f-Screenshot_24.png" />

5. Save the changes and switch to the **[CODE](https://docs.appery.io/docs/apperyio-visual-builder#code-panel)** panel.\
   Here, in the **Variables** section, create 2 variables, both of **String** type: `date` and `time`:

<Image align="center" className="border" border={true} src="https://files.readme.io/5c81e01-Screenshot_39.png" />

Test the app. It should work like this:

<Image align="center" className="border" width="smart" border={true} src="https://files.readme.io/c7b0664-2.gif" />

# Using Custom Datepicker

The **[Datetime](https://docs.appery.io/docs/ionic-5-ui-components-properties#datetime)** and **[Input](https://docs.appery.io/docs/ionic-5-ui-components-properties#input)** components are a good solution if we need to enter only one value. But what if we need to select multiple date values or a date range?\
In this case, [a separate modal screen](https://docs.appery.io/docs/ionic-5-date-and-time-input-sample-app#setting-up-datepicker-app-with-modal-screen) or the [ion2-calendar Modal Mode](https://docs.appery.io/docs/ionic-5-date-and-time-input-sample-app#using-ion2-calendar-modal-mode) can be used.

## Setting Up Datepicker with *DateModal* Page

### Defining *App settings*

1. Go to **Project > App settings >[Npm modules](https://docs.appery.io/docs/appbuilder-app-settings#npm-modules)**.
2. Add a new **Dependency** with ***ion2-calendar*** for its name and ***3.0.0-rc.0*** for its version:

<Image align="center" className="border" border={true} src="https://files.readme.io/3222202-Screenshot_1.png" />

3. Then navigate to **Pages > app >[MODULE](https://docs.appery.io/docs/apperyio-visual-builder#module-panel)**. In the **Imports** section, add: `import { CalendarModule } from 'ion2-calendar';`

<Image align="center" className="border" border={true} src="https://files.readme.io/6bafbc2-Screenshot_3.png" />

4. Scroll down and in the **NgModule Settings > Imports** section, type `CalendarModule`. Save the changes:

<Image align="center" className="border" border={true} src="https://files.readme.io/9d6a5dd-Screenshot_4.png" />

### Adding Options of Date/Time Selection (*Single*, *Multi*, and *Range*)

Let's see how you can set up your app if you, for example, need to select only single date/time combination, select several dates or, select a range of dates.

#### Defining *DateModal* Page

1. Select the **DateModal** page and open its **[DESIGN](https://docs.appery.io/docs/apperyio-visual-builder#design-panel)** panel.
2. Under the **[PROPERTIES](https://docs.appery.io/docs/apperyio-visual-builder#properties-overview)** panel, change its **Footer** property to ***False*** and set **Modal Screen** to ***True***.
3. Then, select its **[Toolbar](https://docs.appery.io/docs/ionic-5-ui-components-properties#toolbar)** component and set its **Color** property to ***tertiary*** and its **Mode** property to ***iOS***; then switch to the **[ToolbarTitle](https://docs.appery.io/docs/ionic-5-ui-components-properties#toolbar-title)** component and change it's **Text** property to ***Select date range***.
4. Now, drag the **[Button](https://docs.appery.io/docs/ionic-5-ui-components-properties#button)** component and drop it to the **[Toolbar buttons](https://docs.appery.io/docs/ionic-5-ui-components-properties#toolbar-buttons)** area, clear its **Text** value, and set its **Icon > Style** property to ***arrow-back***.
5. To make the page to a modal screen, set the **Modal Screen** property of the **Page** component to ***True***, otherwise, this functionality will not work:

<Image align="center" className="border" border={true} src="https://files.readme.io/007fb33-Screenshot_46.png" />

6. Unfold the **[EVENTS](https://docs.appery.io/docs/apperyio-visual-builder#events-tab)** tab from the bottom, select the **Button1** component; for the **Event**, select ***Click***, for the **Action**, select ***[Run Typescript](https://docs.appery.io/docs/5-event-handling#run-typescript)***. Copy the code below and paste it to the code editor.

```typescript
this.Apperyio.getController("ModalController").dismiss();
```

As a result, the button configuration should be like this:

<Image align="center" className="border" border={true} src="https://files.readme.io/a0dd116-Screenshot_25.png" />

7. Also, drag another **[Button](https://docs.appery.io/docs/ionic-5-ui-components-properties#button)** component and drop it to the **[Toolbar buttons](https://docs.appery.io/docs/ionic-5-ui-components-properties#toolbar-buttons)** area; then set its properties as follow:

* **Component Type** = ***Ionic Button***
* **Text** = ***Save***
* **Slot** = ***End***
* **Button Type** = ***Bar Button***.

8. Now, unfold the **[EVENTS](https://docs.appery.io/docs/apperyio-visual-builder#events-tab)** tab from the bottom, and for the **Button2** component ***Click*** event, define the ***[Run Typescript](https://docs.appery.io/docs/5-event-handling#run-typescript)*** action. For the action details, insert the below code and save:

```typescript
this.Apperyio.getController("ModalController").dismiss(this.selectedDates);
```

9. Finally, drag an **[Html](https://docs.appery.io/docs/ionic-5-ui-components-properties#html)** component and drop it to the screen. Click the **Edit** button next to its **HTML** property in the **[PROPERTIES](https://docs.appery.io/docs/apperyio-visual-builder#properties-overview)** panel on the right. Type the following code in a popup and click **Save**:

```html
<ion-calendar [(ngModel)]="selectedDates"
              [options]="options"
              [type]="type"
              [format]="'YYYY-MM-DD'">
</ion-calendar>
```

<Image align="center" className="border" border={true} src="https://files.readme.io/28ee53c-Screenshot_5.png" />

10. Save the changes and switch to the **[CODE](https://docs.appery.io/docs/apperyio-visual-builder#code-panel)** panel.\
    Here, in the **Custom Includes** section, add an include with `{ CalendarComponentOptions }` for its name and set `ion2-calendar` as its path.
11. In the **Variables** section, create 3 variables:

* `selectedDates` variable of **Any** type and `{ from: '', to: '' }` value
* `options` variable of **CalendarComponentOptions** type with `{ pickMode: 'range' }` default value,
* `type` variable of **String** type with `'string'` as its default value:

<Image align="center" className="border" border={true} src="https://files.readme.io/a533ba9-Screenshot_6.png" />

> 📘 Component options
>
> The `type` variable defines the type of the date values, returned from the picker. You can set the following types: `'string'`, `'js-date'`, `'moment'`, `'time'` and `'object'`.
>
> The `pickMode` option sets the picker mode: `'single'`, `'multi'` or `'range'`.
>
> For more information, check the [module documentation](https://www.npmjs.com/package/ion2-calendar#input-properties).

12. Then navigate to the page **[MODULE](https://docs.appery.io/docs/apperyio-visual-builder#module-panel)** panel and in the **Imports** section, add: `import { CalendarModule } from 'ion2-calendar';`\
    Also, scroll down and in the **NgModule Settings > Imports** section, type `CalendarModule`. Save the changes.

#### Defining *CustomPicker* Page

1. Switch to the **CustomPicker** page and open its **[MODULE](https://docs.appery.io/docs/apperyio-visual-builder#module-panel)** panel to add the same modules: `import { CalendarModule } from 'ion2-calendar';` (in the **Imports** section) and `CalendarModule` (in the **NgModule Settings > Imports** section). Save the changes.
2. Now, select its **[CODE](https://docs.appery.io/docs/apperyio-visual-builder#code-panel)** panel. Here, in the **Custom Includes** section, add an include with `{ CalendarComponentOptions }` for its name. Set `ion2-calendar` as its path.
3. In the **Variables** section, create 6 variables:

* `options` variable of **CalendarComponentOptions** type with `{ pickMode: 'single' }` default value,
* `selectedValue` variable of **Any** type
* `type` variable of **String** type with `'string'` as its default value
* `pageTitle` variable of **String** type and `'Pick a date:'` value
* `selectedMode` variable of **String** type and `'single'` value
* `selectedTitle` variable of **String** type and `'Selected value:'` value:

<Image align="center" className="border" border={true} src="https://files.readme.io/292e2ac-Screenshot_26.png" />

4. Now, scroll down to the **Functions** section and add two functions, both of **Method** type:

* `segmentChanged` with `event` as an argument and the below code:

```typescript segmentChanged(event)
const mode = event.detail.value;

this.options = {
    pickMode: mode
};

this.setTitle(mode);
this.selectedMode = mode;
this.selectedValue = null;
```

* `setTitle` with `mode` as an argument and the below code:

```typescript setTitle(mode)
if (mode === 'range') {
    this.pageTitle = 'Pick a date range:';
    this.selectedTitle = 'Selected values range:';
} else if (mode === 'multi') {
    this.pageTitle = 'Pick dates:';
    this.selectedTitle = 'Selected values:';
} else {
    this.pageTitle = 'Pick a date:';
    this.selectedTitle = 'Selected value:';
}
```

When done, the **Functions** section of the **CustomPicker** page **[CODE](https://docs.appery.io/docs/apperyio-visual-builder#code-panel)** panel should look like this:

<Image align="center" className="border" border={true} src="https://files.readme.io/d416813-Screenshot_34.png" />

5. To finish, add the following code to style code editor under the **[SCSS](https://docs.appery.io/docs/apperyio-visual-builder#scss-panel)** tab:

```css
.hidden {
    display: none;
}
```

<Image align="center" className="border" border={true} src="https://files.readme.io/50f926d-Screenshot_27.png" />

Let's do the page UI now.

5. Open the **CustomPicker** page **[DESIGN](https://docs.appery.io/docs/apperyio-visual-builder#design-panel)** panel and under the **[PROPERTIES](https://docs.appery.io/docs/1-creating-an-app-ui-palette#properties-overview)** panel, set the **Page Footer** property to ***False***, then select its **[Toolbar](https://docs.appery.io/docs/ionic-5-ui-components-properties#toolbar)** component and set its **Color** property to ***tertiary*** and its **Mode** property to ***iOS***; then switch to the **[ToolbarTitle](https://docs.appery.io/docs/ionic-5-ui-components-properties#toolbar-title)1** component and change it's **Text** property to ***Custom ion2-calendar picker***.
6. Then, from the **[PALETTE](https://docs.appery.io/docs/1-creating-an-app-ui-palette#ui-components-palette-overview)**, drag & drop the **[Button](https://docs.appery.io/docs/ionic-5-ui-components-properties#button)** component to the **[Toolbar buttons](https://docs.appery.io/docs/ionic-5-ui-components-properties#toolbar-buttons)** area and set its **Component type** property to ***[Ionic Back Button](https://docs.appery.io/docs/ionic-5-ui-components-properties#ionic-back-button)***.
7. Drag two **[Grid](https://docs.appery.io/docs/ionic-5-ui-components-properties#grid)** components and drop them to the **[Content](https://docs.appery.io/docs/2-creating-an-app-ui-pages-and-tabs#content-component)** area.\
   Two grids will be created each nesting one default **[Grid Row](https://docs.appery.io/docs/ionic-5-ui-components-properties#grid-row)** with two child **[Grid Cell](https://docs.appery.io/docs/ionic-5-ui-components-properties#grid-cell)** components.
8. For each row, select the right **[Grid Cell](https://docs.appery.io/docs/ionic-5-ui-components-properties#grid-cell)** and remove them from by using the **[Context menu](https://docs.appery.io/docs/1-creating-an-app-ui-palette#context-menu-overview)** or simply click the red **cross** icon.
9. Drag per one **[Html](https://docs.appery.io/docs/ionic-5-ui-components-properties#html)** component and drop them  to both grid cells. Then, define them one by one by clicking the **Edit** button next to their **HTML** property in the **[PROPERTIES](https://docs.appery.io/docs/apperyio-visual-builder#properties-overview)** panel on the right. Type the following codes in a popup and click **Save**:

<Image align="center" className="border" border={true} src="https://files.readme.io/d760815-Screenshot_28.png" />

* for **Html1**:

```html
<ion-segment color="tertiary" (ionChange)="segmentChanged($event)" value="single">
  <ion-segment-button value="single">
    <ion-label>Single</ion-label>
  </ion-segment-button>
  
  <ion-segment-button value="multi">
    <ion-label>Multiple</ion-label>
  </ion-segment-button>
  
  <ion-segment-button value="range">
    <ion-label>Range</ion-label>
  </ion-segment-button>
</ion-segment>
```

* for **Html2**:

```html
<ion-calendar [(ngModel)]="selectedValue"
              [options]="options"
              [type]="type"
              [format]="'YYYY-MM-DD'">
</ion-calendar>
```

10. Move to the second **[Grid](https://docs.appery.io/docs/ionic-5-ui-components-properties#grid)** and define its **[Grid Row](https://docs.appery.io/docs/ionic-5-ui-components-properties#grid-row)** by setting its **Justify Content** property to ***start***.
11. Then, drag another **[Grid](https://docs.appery.io/docs/ionic-5-ui-components-properties#grid)** component and three **[List](https://docs.appery.io/docs/ionic-5-ui-components-properties#list)** components  and drop them to the **[Grid Cell](https://docs.appery.io/docs/ionic-5-ui-components-properties#grid-cell)**&#x32;.
12. First, let's define the left grid cell:\
    Set its **Text Alignment** property to ***text-center*** and then drop an **[Icon](https://docs.appery.io/docs/ionic-5-ui-components-properties#icon)** inside the grid cell.

* For the icon, set:
* **Name**= ***calendar*** (click the **Default icon** button to select the icon you need)
* **Color** = ***tertiary***.

13. Switch to the right grid cell and set its **Align Self** property to ***center***. Also, drag & drop the **\*[Text](https://docs.appery.io/docs/ionic-5-ui-components-properties#text)** component to the **[Grid Cell](https://docs.appery.io/docs/ionic-5-ui-components-properties#grid-cell)**, replace its default **Text** property with ***\{\{selectedTitle}}*** and set its **Container** property as ***h3***. After that, switch to the text **Styles** tab and set the **Class** property to ***ion-margin-horizontal***:

<Image align="center" className="border" border={true} src="https://files.readme.io/883f421-Screenshot_38.png" />

It's time to define the lists:

* **List 1**:
* **Mode** = ***iOS***
* **ngIf** = ***selectedMode === 'single'***\
  Then, delete the second **[List item](https://docs.appery.io/docs/ionic-5-ui-components-properties#list-item)** and define the **Text** property of the first item **[Item Label](https://docs.appery.io/docs/ionic-5-ui-components-properties#item-label)** to ***\{\{ selectedValue ? (selectedValue | date) : 'not selected'}}***.
* **List 2**:
* **Mode** = ***iOS***
* **ngIf** = ***selectedMode === 'multi'***
* For the first list item (**ListItem3**), set its **\*ngFor** property to ***let item of selectedValue*** and set the **Text** property of its **[Item Label](https://docs.appery.io/docs/ionic-5-ui-components-properties#item-label)** to ***\{\{ item | date }}***.
* For the second list item (**ListItem4**), first, set its **\*ngFor** property to ***let item of selectedValue***:

<Image align="center" className="border" border={true} src="https://files.readme.io/fb183a9-Screenshot_32.png" />

and then set the **Text** property of its **[Item Label](https://docs.appery.io/docs/ionic-5-ui-components-properties#item-label)** to ***not selected***.

* **List 3**:
* **Mode** = ***iOS***
* **ngIf** = ***selectedMode === 'range'***
* for the first list item (**ListItem5**), set the **Text** property of its **\*[Item Label](https://docs.appery.io/docs/ionic-5-ui-components-properties#item-label)** to ***From: \{\{ selectedValue ? (selectedValue.from | date) : 'not selected'}}***.
* for the second list item (**ListItem6**), set the **Text** property of its **[Item Label](https://docs.appery.io/docs/ionic-5-ui-components-properties#item-label)** to ***To: \{\{ selectedValue ? (selectedValue.to | date) : 'not selected'}}***:

<Image align="center" className="border" border={true} src="https://files.readme.io/35e222b-Screenshot_33.png" />

14. Save all the changes and test how selecting different options (***single***, ***multi***, and ***range***) works in one app page:

<Image align="center" className="border" width="smart" border={true} src="https://files.readme.io/cbb2200-3.gif" />

## Adding Custom Datepicker with Appery.io Modal Screen

1. Switch to the ***CustomPickerModal*** page **[DESIGN](https://docs.appery.io/docs/apperyio-visual-builder#design-panel)** panel, set the **Page Footer** property to ***False*** and change the Header **ToolbarTitle** **Text** to **Custom picker in a modal**.
2. Then, select its **[Toolbar](https://docs.appery.io/docs/ionic-5-ui-components-properties#toolbar)** component and set its **Color** property to ***tertiary*** and its **Mode** property to ***iOS***.
3. From the **[PALETTE](https://docs.appery.io/docs/creating-an-app-ui-palette#ui-components-palette-overview)** panel, drag and drop the **[Button](https://docs.appery.io/docs/ionic-5-ui-components-properties#button)** component to the **[Toolbar buttons](https://docs.appery.io/docs/ionic-5-ui-components-properties#toolbar-buttons)** area and set its **Component type** property to  to ***[Ionic Back Button](https://docs.appery.io/docs/ionic-5-ui-components-properties#ionic-back-button)***.
4. Now, drag the **[Grid](https://docs.appery.io/docs/ionic-5-ui-components-properties#grid)** component and drop it to the **[Content](https://docs.appery.io/docs/2-creating-an-app-ui-pages-and-tabs#content-component)** area.\
   A grid will be created nesting one default **[Grid Row](https://docs.appery.io/docs/ionic-5-ui-components-properties#grid-row)** with two child **[Grid Cell](https://docs.appery.io/docs/ionic-5-ui-components-properties#grid-cell)** components.
5. Delete the right **[Grid Cell](https://docs.appery.io/docs/ionic-5-ui-components-properties#grid-cell)**.
6. Drag & drop two **[Text](https://docs.appery.io/docs/ionic-5-ui-components-properties#text)** components to the **[Grid Cell](https://docs.appery.io/docs/ionic-5-ui-components-properties#grid-cell)** and set the **Text** property of the first text to ***ion2-calendar date range picker*** and its **Container** property to ***h3***. After that, switch to the text **Styles** tab and set the **Class** property to ***ion-margin-horizontal***.
7. Now, select the second **[Text](https://docs.appery.io/docs/ionic-5-ui-components-properties#text)** component and set its  **Container** property to ***ion-note*** and its **Text** property to ***Opens in a modal screen (DateModal page)***.
8. Now, drag the **[Button](https://docs.appery.io/docs/ionic-5-ui-components-properties#button)** component and drop it below the texts; then and set its **Text** as ***Select dates***.
9. Then, switch to the button **Styles** tab and set the **Class** property to ***ion-margin-vertical***, **Mode** = ***iOS***, **Button Color** = ***Tertiary***, and **Shape** = ***Round***.
10. To finish with the button, define its **(click)** event with the ***[Run TypeScript](https://docs.appery.io/docs/5-event-handling#run-typescript)*** action. Copy the code below and paste it to the code editor.

```typescript
this.Apperyio.showModal("DateModal", {
        componentProps: {},
        showBackdrop: true,
        backdropDismiss: true,
        cssClass: "modal",
        animated: true,
        keyboardClose: true
    })
    .then(modal => {
        modal.present();
        modal.onDidDismiss().then((dataReturned) => {
            this.selectedDates = dataReturned.data;
        });
    });
```

<Image align="center" className="border" border={true} src="https://files.readme.io/5e79459-Screenshot_36.png" />

11. Now, drag the **[List](https://docs.appery.io/docs/ionic-5-ui-components-properties#list)** component and drop it to the **[Grid Cell](https://docs.appery.io/docs/ionic-5-ui-components-properties#grid-cell)**.
12. Inside the list, for the first **[List item](https://docs.appery.io/docs/ionic-5-ui-components-properties#list-item)**, set its label's **Text** property to ***From: \{\{ selectedDates?.from | date }}***. For the second one — to ***To: \{\{ selectedDates?.to | date }}***.

Here is how the resulting page UI should look like:

<Image align="center" className="border" width="smart" border={true} src="https://files.readme.io/8875171-Screenshot_44.png" />

13. Navigate to the page **[CODE](https://docs.appery.io/docs/apperyio-visual-builder#code-panel)** panel and add a `selectedDates` variable of **Any** type and `{ from: '', to: '' }` value:

<Image align="center" className="border" border={true} src="https://files.readme.io/3e21501-Screenshot_37.png" />

Save the changes and test the app. Now you can select a range of dates using the modal screen functionality by clicking the start and the end dates:

<Image align="center" className="border" border={true} src="https://files.readme.io/5b4621a-4.gif" />

## Using *ion2-calendar* Modal Mode

In the previous steps, we created a separate modal screen to display the date picker. Another option is to use `ion2-calendar`'s [Modal Mode](https://www.npmjs.com/package/ion2-calendar#modal-mode).

1. Open the **Datetime** page **[DESIGN](https://docs.appery.io/docs/apperyio-visual-builder#design-panel)** panel, set the **Page Footer** property to ***False*** and change the Header **ToolbarTitle** **Text** to **Custom picker in a modal**.
2. Then, select its **[Toolbar](https://docs.appery.io/docs/ionic-5-ui-components-properties#toolbar)** component and set its **Color** property to ***tertiary*** and its **Mode** property to ***iOS***.
3. From the **[PALETTE](https://docs.appery.io/docs/creating-an-app-ui-palette#ui-components-palette-overview)** panel, drag and drop the **[Button](https://docs.appery.io/docs/ionic-5-ui-components-properties#button)** component to the **[Toolbar buttons](https://docs.appery.io/docs/ionic-5-ui-components-properties#toolbar-buttons)** area and set its **Component type** property to  to ***[Ionic Back Button](https://docs.appery.io/docs/ionic-5-ui-components-properties#ionic-back-button)***.
4. Now, drag the **[Grid](https://docs.appery.io/docs/ionic-5-ui-components-properties#grid)** component and drop it to the **[Content](https://docs.appery.io/docs/2-creating-an-app-ui-pages-and-tabs#content-component)** area.\
   A grid will be created nesting one default **[Grid Row](https://docs.appery.io/docs/ionic-5-ui-components-properties#grid-row)** with two child **[Grid Cell](https://docs.appery.io/docs/ionic-5-ui-components-properties#grid-cell)** components.
5. Delete the right **[Grid Cell](https://docs.appery.io/docs/ionic-5-ui-components-properties#grid-cell)**.
6. Drag the **[Text](https://docs.appery.io/docs/ionic-5-ui-components-properties#text)** component and drop it to the **[Grid Cell](https://docs.appery.io/docs/ionic-5-ui-components-properties#grid-cell)**; then set its **Text** property to ***Modal Mode provided by ion2-calendar*** and its **Container** property as ***h3***. After that, switch to the text **Styles** tab and set the **Class** property to ***ion-margin-horizontal***.
7. Now, drag the **[Button](https://docs.appery.io/docs/ionic-5-ui-components-properties#button)** component and drop it below the text; then set its **Text** =***Select date range*** and define its **(click)** property as ***showDatepicker()***:

<Image align="center" className="border" border={true} src="https://files.readme.io/dcc3c73-Screenshot_43.png" />

8. Then, switch to the button **Styles** tab and set the **Class** property to ***ion-margin-vertical***, **Mode** = ***iOS***, **Button Color** = ***Tertiary***, and **Shape** = ***Round***:

<Image align="center" className="border" border={true} src="https://files.readme.io/17ee3c7-Screenshot_42.png" />

9. Now, drag a **[List](https://docs.appery.io/docs/ionic-5-ui-components-properties#list)** component and drop it below the  button.
10. Inside the **List**, for the first **[List Item](https://docs.appery.io/docs/ionic-5-ui-components-properties#list-item)**, set the **ItemLabel** **Text** property to ***From: \{\{selectedDates?.from | date}}***. For the second one — to ***To: \{\{selectedDates?.to | date}}***.
11. For the button, set **Text** to ***Select dates*** and define its **(click)** property as ***openDatePicker()***:

<Image align="center" className="border" border={true} src="https://files.readme.io/29f40ef-Button.jpg" />

9. Navigate to the **[CODE](https://docs.appery.io/docs/apperyio-visual-builder#code-panel)** panel. In the **Internal Includes** section, click the **Edit internal includes** button. In the popup, select the ***\{ ModalController } from "@ionic/angular"*** include and save:

<Image align="center" className="border" width="smart" border={true} src="https://files.readme.io/7097ac8-Dependencies.jpg" />

10. Also, add the following **Custom Includes**:

* with `{ CalendarComponentOptions }` for name and `ion2-calendar` path,
* with `{ CalendarModal }` for name and `ion2-calendar` path:

11. Scroll down to the **Variables** section and create 3 variables:

* `type` variable of **String** type with `'string'` as its default value
* `selectedDates` variable of **Any** type and `{ from: '', to: '' }` value
* `modalController` variable of **ModalController** type (select the **Add DI** check box).

12. In the **Functions** section, create a new `showDatepicker` **Async method**. In the code editor, type the following code for the new function:

```typescript openDatePicker
const options = {
  pickMode: 'range',
  title: 'Select date range'
};

const calendarModal = await this.modalController.create({
    component: CalendarModal,
    componentProps: { options }
});

calendarModal.onDidDismiss().then(({ data }) => {
    if (data) {
        this.selectedDates.from = data.from.dateObj;
        this.selectedDates.to = data.to.dateObj;
    }
})

return await calendarModal.present();
```

Here is how the page **[CODE](https://docs.appery.io/docs/apperyio-visual-builder#code-panel)** panel should look like:

<Image align="center" className="border" border={true} src="https://files.readme.io/f3c959c-Screenshot_41.png" />

Finally, navigate to the page **[MODULE](https://docs.appery.io/docs/apperyio-visual-builder#module-panel)** panel and in the **Imports** section, add: `import { CalendarModule } from 'ion2-calendar';`\
Also, scroll down and in the **NgModule Settings > Imports** section, type `CalendarModule`.

# Testing App

Save the changes and test the app:

<Image align="center" className="border" width="smart" border={true} src="https://files.readme.io/1c53a3c-5.gif" />

> 📘 Customizing ion2-calendar datepicker
>
> You can customize the component more flexibly. It supports:
>
> * selecting single date, date range and multi date.
> * HTML components.
> * disabling weekdays or weekends.
> * setting days event.
> * setting localization and calendar appearance.
>
> Information on available properties and methods can be found [in documentation]().

> 🚧
>
> Note that ***ion2-calendar*** can be used precisely for the selection of date values. If you need to create integration with the native calendar app, please check [Ionic Calendar plug-in tutorial](https://docs.appery.io/docs/ionic-5-calendar-plugin-tutorial).

## Testing on Device

When your app version is ready, you might also like to [test](https://docs.appery.io/docs/9-testing-your-app) it on the device.

> 👍 Appery.io Tester App
>
> A great option to quickly test the app on the device is to use our **Appery.io Tester** app.\
> The app is free and available for both [iOS](https://apps.apple.com/app/id737478069) and [Android](https://play.google.com/store/apps/details?id=io.appery.tester\&hl=en).\
> You can check out [this](https://docs.appery.io/docs/apperyio-tester-app) page to learn more about using the **Appery.io Tester** app.

<Image align="center" className="border" width="smart" border={true} src="https://files.readme.io/8db98cd-06-07_16.19..png" />