An Angular date range that stores the time too
Ply — ply-ui.com binds a start and end datetime in one field. showTime on date-range-picker adds a clock for each day. Try the reservation field on this page.
Reservation field
Bound value
Start not set → End not set
Stored as { start: Date, end: Date }
<ply-date-range-picker
showTime
hourCycle="24"
label="Reservation"
[(ngModel)]="stay">
</ply-date-range-picker>Ply — ply-ui.com binds a reservation as two JavaScript Dates, not a pair of text fields. Set showTime on ply-date-range-picker and the same popup asks for the start day, the end day, then a time for each. One datetime uses ply-datepicker with showTime. Time of day only uses the free ply-time-picker. The field at the top of this page is that control.
Switch the three modes, flip 12-hour and 24-hour, and apply a range. The readout and the snippet update together. The full catalog demo, including the date-only range, is at /base-elements/datepicker/.
Why one native input is not the reservation form
input type="datetime-local" has been widely available since October 2021. MDN still warns that "The control's UI varies in general from browser to browser," and the value is a local date and time with no time zone. A stay needs two of those values, in an order, with the same clock. Two native inputs leave the pairing, the swap, and the popup to you.
Angular template-driven forms bind that pair with ngModel. The copied template is ordinary Tailwind CSS, so the field matches the rest of the app after npx ply-ui-cli add.
Which field to use
| Need | Control | What ngModel stores |
|---|---|---|
| Start and end, with a time on each day | ply-date-range-picker and showTime |
{ start: Date, end: Date } |
| One date and a time | ply-datepicker and showTime |
Date |
| Hours and minutes only | ply-time-picker (free) |
HH:mm string |
| A month that stays on the page | ply-calendar (free) |
a date, or a range, with no popup |
hourCycle is "24" or "12" on all three popup fields. The toggle above the demo writes that attribute into the snippet.
An inline month belongs on ply-calendar. A reminder that is only a clock belongs on ply-time-picker.
What happens inside the popup
showTime keeps the calendar and the clocks in one dropdown.
- Pick the start day, then the end day. Choose times stays disabled until both days are set.
- The panel switches to a start clock and an end clock. Change dates goes back.
- Apply writes both datetimes and closes the popup.
If the end is earlier than the start — including a same-day stay whose end clock is before the start clock — Apply swaps them so the start stays first. Reopening the field restores the dates and the times you applied.
The popup is a calendar grid, not a dialog. Arrow keys move the focused day. Escape closes and returns focus to the field. That is the WAI-ARIA grid pattern used by the datepicker page, not a claim that the whole catalog is WCAG compliant. Notes for the live demo sit on /base-elements/datepicker/.
The overlay skips DOM work on the server, so the article and the demo page can prerender. The same pattern is covered in the SSR write-up.
Copy it in
date-range-picker and datepicker are Pro. The license is checked when the CLI downloads them. time-picker and calendar are free.
npx ply-ui-cli add date-range-picker
<ply-date-range-picker
showTime
hourCycle="24"
label="Reservation"
[(ngModel)]="stay">
</ply-date-range-picker>
stay is { start: Date | null; end: Date | null }. Format it with Angular's DatePipe and the short format when the readout should include the time. The files land in your repo. Edits after that are yours — the longer version of that boundary is The component lives in your repo.
Frequently asked questions
Same wording as the canonical FAQ.
Yes. Pro date-range-picker binds a start and end date. Set showTime to choose a time for each day in the same popup; hourCycle is 12 or 24. datepicker showTime does the same for one datetime. Time of day only is the free time-picker. Install with npx ply-ui-cli add date-range-picker. Walkthrough: /learn/angular-date-range-with-time/. Live demo: /base-elements/datepicker/.
npx ply-ui-cli init once per project, then npx ply-ui-cli add <name>. Omit the name in a terminal to pick from the catalog (filter, then type to select). --yes and CI need explicit names. Components land in src/app/components/<name>/ by default and are yours.
Yes. The docs site prerenders every catalog route to static HTML, and a blocking CI job fails the build if any route stops rendering.
Components ship with ARIA and focus states. Axe-core in CI opens combobox, dropdown menu, menubar, and dialog. Data-table key specs are Enter and Space. An Accessibility Conformance Report is at /accessibility/.
Start with the free tier
All primitives, all 19 form blocks, and 392 outline icons — no account, no licence key.