
Security News
Socket Releases Free Certified Patches for Critical vm2 Sandbox Escape
A critical vm2 sandbox escape can allow untrusted JavaScript to break isolation and execute commands on the host Node.js process.
@katyan/datetime-picker
Advanced tools
A DatetimePicker like @angular/material Datepicker by adding support for choosing time.
@see LIVE DEMO AND DOCUMENTATION
@see DEMO stackblitz

Choose the version corresponding to your Angular version:
| Angular | @katyan/datetime-picker |
|---|---|
| 20 | 20.x+ |
| 19 | 19.x+ |
| 18 | 18.x+ |
| 17 | 17.x+ |
npm install --save @katyan/datetime-picker
Add the date provider to your app configuration.
** Note: ** to prevent the ERROR Error: NgxMatDatetimePicker: No provider found for NgxMatDateAdapter. You must import one of the following modules at your application root: NgxMatNativeDateModule, NgxMatMomentDateModule, or provide a custom implementation.
import { provideNgxMatNativeDate } from '@katyan/datetime-picker';
export const appConfig: ApplicationConfig = {
providers: [
...,
provideNgxMatNativeDate(),
...,
],
};
On your component, you can use the datepicker as follows:
import {
NgxMatDatepickerActions,
NgxMatDatepickerApply,
NgxMatDatepickerCancel,
NgxMatDatepickerClear,
NgxMatDatepickerInput,
NgxMatDatetimepicker,
} from '@katyan/datetime-picker';
@Component({
selector: 'test',
imports: [
NgxMatDatepickerActions,
NgxMatDatepickerActions,
NgxMatDatepickerApply,
NgxMatDatepickerCancel,
NgxMatDatepickerClear,
NgxMatDatepickerInput,
NgxMatDatetimepicker,
..., // other imports
],
template: `
<input matInput [ngxMatDatetimePicker]="event" class="hidden" />
<ngx-mat-datetime-picker #event>
<ngx-mat-datepicker-actions>
<div class="flex w-full justify-between">
<button mat-button ngxMatDatepickerClear>Clear</button>
<div>
<button mat-button ngxMatDatepickerCancel>Cancel</button>
<button mat-raised-button color="primary" ngxMatDatepickerApply>Apply</button>
</div>
</div>
</ngx-mat-datepicker-actions>
</ngx-mat-datetime-picker>
`,
})
export class TestComponent {}
@see src/app/demo-datetime/demo-datetime.module.ts
docs](https://material.angular.io/components/datepicker/api)) ### Datetime Picker (ngx-mat-datetime-picker)
<mat-form-field>
<input matInput [ngxMatDatetimePicker]="picker" placeholder="Choose a date" [formControl]="dateControl" [min]="minDate" [max]="maxDate" [disabled]="disabled" />
<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
<ngx-mat-datetime-picker #picker [showSpinners]="showSpinners" [showSeconds]="showSeconds" [stepHour]="stepHour" [stepMinute]="stepMinute" [stepSecond]="stepSecond" [touchUi]="touchUi" [color]="color" [enableMeridian]="enableMeridian" [disableMinute]="disableMinute" [hideTime]="hideTime"> </ngx-mat-datetime-picker>
</mat-form-field>
<ngx-mat-timepicker [(ngModel)]="date"></ngx-mat-timepicker>
<ngx-mat-timepicker [(ngModel)]="date" [disabled]="disabled"></ngx-mat-timepicker>
<ngx-mat-timepicker [(ngModel)]="date" [stepHour]="2" [stepMinute]="5" [stepSecond]="10"></ngx-mat-timepicker>
<ngx-mat-timepicker [(ngModel)]="date" [showSpinners]="showSpinners"></ngx-mat-timepicker>
<ngx-mat-timepicker [(ngModel)]="date" [showSeconds]="showSeconds"></ngx-mat-timepicker>
<ngx-mat-timepicker [(ngModel)]="date" [disableMinute]="disableMinute"></ngx-mat-timepicker>
<ngx-mat-timepicker [(ngModel)]="date" [defaultTime]="defaultTime"></ngx-mat-timepicker>
<ngx-mat-timepicker [formControl]="formControl"></ngx-mat-timepicker>
You can use all @Input of ngx-mat-timepicker for ngx-mat-datetime-picker
| @Input | Type | Default value | Description |
|---|---|---|---|
| disabled | boolean | null | If true, the picker is readonly and can't be modified |
| showSpinners | boolean | true | If true, the spinners above and below input are visible |
| showSeconds | boolean | true | If true, it is not possible to select seconds |
| disableMinute | boolean | false | If true, the minute (and second) is readonly |
| defaultTime | Array | undefined | An array [hour, minute, second] for default time when the date is not yet defined |
| stepHour | number | 1 | The number of hours to add/substract when clicking hour spinners |
| stepMinute | number | 1 | The number of minutes to add/substract when clicking minute spinners |
| stepSecond | number | 1 | The number of seconds to add/substract when clicking second spinners |
| color | ThemePalette | undefined | Color palette to use on the datepicker's calendar. |
| enableMeridian | boolean | false | Whether to display 12H or 24H mode. |
| hideTime | boolean | false | If true, the time is hidden. |
| touchUi | boolean | false | Whether the calendar UI is in touch mode. In touch mode the calendar opens in a dialog rather than a popup and elements have more padding to allow for bigger touch targets. |
The datepicker was built to be date implementation agnostic. This means that it can be made to work with a variety of different date implementations. However it also means that developers need to make sure to provide the appropriate pieces for the datepicker to work with their chosen implementation.
The easiest way to ensure this is to import one of the provided date modules:
| NgxMatNativeDateModule | NgxMatMomentModule | |
|---|---|---|
| Date type | Date | Moment |
| Supported locales | en-US | See project for details |
| Dependencies | None | Moment.js |
| Import from | @katyan/datetime-picker | @katyan/moment-adapter |
To use NgxMatMomentModule:
npm install --save @katyan/moment-adapter
Please note: NgxMatNativeDateModule is based off the functionality available in JavaScript's native Date object. Thus it is not suitable for many locales. One of the biggest shortcomings of the native Date object is the inability to set the parse format.
We highly recommend using the NgxMatMomentModule or a custom NgxMatDateAdapter that works with the formatting/parsing library of your choice.
For example:
Creating a custom date adapter:
@Injectable()
export class CustomDateAdapter extends NgxMatDateAdapter<D> {...}
// D can be Date, Moment or customized type
Creating a custom date adapter module
@NgModule({
providers: [
{
provide: NgxMatDateAdapter,
useClass: CustomDateAdapter,
deps: [MAT_DATE_LOCALE, NGX_MAT_MOMENT_DATE_ADAPTER_OPTIONS]
}
],
})
export class CustomDateModule { }
You can also customize the date format by providing your custom NGX_MAT_DATE_FORMATS in your module.
// If using Moment
const CUSTOM_DATE_FORMATS: NgxMatDateFormats = {
parse: {
dateInput: "l, LTS"
},
display: {
dateInput: "l, LTS",
monthYearLabel: "MMM YYYY",
dateA11yLabel: "LL",
monthYearA11yLabel: "MMMM YYYY"
}
};
//and in the module providers
providers: [
{ provide: NGX_MAT_DATE_FORMATS, useValue: CUSTOM_MOMENT_FORMATS }
]
<link href="https://fonts.googleapis.com/icon?family=Material+Icons&display=block" rel="stylesheet">
MIT
FAQs
Angular Material Datetime Picker
The npm package @katyan/datetime-picker receives a total of 132 weekly downloads. As such, @katyan/datetime-picker popularity was classified as not popular.
We found that @katyan/datetime-picker demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
A critical vm2 sandbox escape can allow untrusted JavaScript to break isolation and execute commands on the host Node.js process.

Research
Five malicious NuGet packages impersonate Chinese .NET libraries to deploy a stealer targeting browser credentials, crypto wallets, SSH keys, and local files.

Security News
pnpm 11 turns on a 1-day Minimum Release Age and blocks exotic subdeps by default, adding safeguards against fast-moving supply chain attacks.