I have trouble with converting my date format into a good one that can be sent to my database. At default I have the current day set in my dateTimePicker
at 08:00 am. When I want to send it it's format is like this "2020-12-01T07:00:00.812Z"
.What I try to achieve is "2020-12-01 08-00"
so not only the format is bad but it's an hour before the chosen time. I tried converting with moment.js but nothing happens.
Here's the code I tried:
// form where I can pick the date //
ngOnInit() {
this.data= this.formBuilder.group({
id: [],
dateFrom: [this.setTime(), Validators.required],
dateTo: [this.getNextWeek(), Validators.required],
status: [-1],
});
}
// function where I try to convert the date to a useable form //
dataModify(object) {
let formattedObject = {
id: "",
dateFrom: object.dateFrom,
dateTo: object.dateTo,
status: object.status,
};
moment.utc(object.dateFrom).format('YYYY-MM-DD HH:mm');
moment.utc(object.dateTo).format('YYYY-MM-DD HH:mm');
return formattedObject;
}