Allow multiple DateFormats in datepicker
See original GitHub issueBug, feature request, or proposal:
feature
What is the expected behavior?
I want to use 2 different Date Formats in one Component.
idea
{
provide: MAT_DATE_FORMATS, useValue: {
"date": DATE_FORMATS,
"other": OTHER_DATE_FORMATS,
...
}
}
...
<mat-datepicker dateFormat="date"></mat-datepicker>
...
<mat-datepicker dateFormat="other"></mat-datepicker>
...
What is the current behavior?
I can replace Date Formats for component.
What are the steps to reproduce?
What is the use-case or motivation for changing an existing behavior?
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
Is there anything else we should know?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:10
- Comments:8 (4 by maintainers)
Top Results From Across the Web
jQuery Datepicker that supports multiple formats
This 'Unobtrusive Date-Picker Widget V5' seems to accept multiple formats. I did a quick test of all three of the formats you supplied, ......
Read more >How can add multiple date formats in datepicker?
Greetings friends , I have the following code: $(function() { $( "#inicio" ).datepicker({ dateFormat: "yy-mm-dd" }); $( "#termino" ) ...
Read more >How to allow multiple input formats? · Issue #605 - GitHub
The dateFormat prop can accept an array of formats where they will all be used for reading but the first one is used...
Read more >Angular Material datepicker with many custom date formats |
Hi! In this article, I'd like to show you how to create datepickers with many custom date formats in Angular Material. Introduction. Hi!...
Read more >How to Allow Date Range or Multiple Dates in Date Picker
Would you like to customize the date picker to allow for a date range or even multiple dates? You can easily accomplish this...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
If you’re looking for a way to have a couple static formats, it is possible: https://stackblitz.com/edit/angular-azrzg5?file=app/datepicker-moment-example.ts
Unfortunately, if you want to have it be dynamic based on a directive input (e.g.
<mat-form-field dateFormat="LL">
) This won’t work because there isn’t currently a mechanism to tell the datepicker that the format has updated.It would be nice to make the more dynamic version work as well, but its not super high on our priority list
What was the error you were seeing? I don’t think it should be necessary to import @angular/compiler. I updated my stackblitz to the latest version of Angular and it still seems to be working without that import: https://stackblitz.com/edit/angular-azrzg5-pky8e5?file=main.ts