Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 67527

How to first convert FormGroup date to systimestamp before post request

$
0
0

I have date of systimestamp(2020-10-20 23:16:24.727272) in my object which come from the DB which I intend to edit. .substring(0, 10) was used so on the edit form I got 2020-10-20, now after I edited the data and submited the form, I want the date to be converted back to the systimestamp(2020-10-20 23:16:24.727272) format on POST request.

I already read on date conversion but the question here is if it is possible to access the 2020-10-20 coming from FormGroup and convert it before calling post request.

comp.ts

//data to be edited
{
"game": "away",
"date": "2020-10-20 23:16:24.727272"
}

//show data on form
gameDetail(data: any) {
  this.formData.controls.game.setValue( data.game );
  this.formData.controls.date.setValue( data.date.substring(0, 10) );
}

//after edit and submit button
postEdit() {
        // ....is it possible to convert or .getTime() the data here before update. 
        //The "this.formData.value" holds the object new values
  this.service.update( this.formData.value )
    .subscribe( data => {
         this.data = data;
     }
}

html

<form [formGroup]="formData" (ngSubmit)="postEdit()">
   //.......

I want to know how to access the form date for manipulation..


Viewing all articles
Browse latest Browse all 67527

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>