Reputation: 203
I used input type "date" as below,
<input type="date" class="form-control input-sm pull-right" name="order_date" placeholder="Created At"
id="l1" [(ngModel)]="order_date">
It gives the result with "YYYY-MM-DD" format.
I need the result as "DD-MM-YYYY" with the input type of "date'.Any idea to overcome this!
Upvotes: 0
Views: 1407
Reputation: 1
var newDatepickerDate = new Date(23/03/1999);
var startup = newDatepickerDate.toLocaleDateString();
var datePickerdate =startup.replace(/\b(\d\/)/g,'0$1');
var i = datePickerdate;
var dayMonthYear= i.replace(/(\d\d)\/(\d\d)\/(\d{4})/, "$3-$1-$2");
Upvotes: 0
Reputation: 3740
Use:
(ngModelChange)=setDate(order_date)
And in component:
setDate(date:Date){
payload.date = date; // to save payload
}
Upvotes: 1
Reputation: 659
Use {{date | date:'ddMMyyyy'}}
instead of {{date | date:'dd MM yyyy'}}
Upvotes: 1