Reputation: 10335
I use nebular datepicker on my project, on backend we just need the date only without hour and min, so we trim the date. but nebular sending the date on iso date format. thats the problem. When I type like Jul 23 2021, the date in my form formated like 2021-07-22T17:00:0000Z On the server, we got 2021-07-22 instead of 2021-07-23 So I need way to solve this? Can I have setting in nebular to disable the iso format ?
ps: i use angular 11, nebular from ngx-admin
Sc from frontend:
sc from backend: (Dotnet C#)
Upvotes: 0
Views: 893
Reputation: 368
Allegedly, you can use NbDateFnsDateModule to provide a format for your date, I could not get it working though personally.
EDIT: It worked for me providing the format in such an escaped way: format="'DD[/]MM[/]YYYY'"
, e.g.
<nb-datepicker
#datepickerLeft
format="'DD[/]MM[/]YYYY'"
(dateChange)="setCorrectDate($event, field.name, 'datepicker');"></nb-datepicker>
EDIT 2: If the first one doesn't work, try this format:
format="dd-MM-yyyy"
Upvotes: 0
Reputation: 959
Since you only need a date and not date-time combined I would suggest that you trim the ISO format date to a normal date string like this:
let dateFromInput = "2013-08-03T02:00:00Z";
let newDate = dateFromInput.substring(0, 10);
console.log("dateFromInput ", dateFromInput);
console.log("newDate ", newDate); // 2013-08-03
Upvotes: 1