Ok so this question has been asked here however the solutions given don't seem to resolve my issue.
When I click save I refer to the these fields and create a date as shown here:
this.profile.date_of_birth = new Date(this.editProfileForm.value['year'], this.editProfileForm.value['month'], this.editProfileForm.value['day']);
Which when logged to the console reads:
Fri Dec 23 1988 00:00:00 GMT+1100 (AEDT)
I then make a call to my nodejs
application which is running on http://localhost:3005
, which takes the data and saves it to mongodb
, before the save happens I log the value of date_of_birth as shown here:
api.put('/update', authenticate, (req, res) => {
console.log(req.body.date_of_birth);
// Save properties
});
however this logs:
1988-12-22T13:00:00.000Z
which is a day off....
I'm not doing any formatting before creating a new date when the user presses save, so I'm unsure into why when it leaves the front end application, and gets to the backend application the date is displayed incorrect....
The actual call to the nodejs
application is here:
saveProfile(profileId: string, token: string, profile: Profile): Observable<any> {
var body = {
"id": profile.id,
"date_of_birth": profile.date_of_birth,
}
return this.http.put(UPDATE_EDIT_PROFILE, body, {
headers: this.setHeaders(token)
}).map((res: any) => res.json());
}
Can anyone recommend what could possibly going wrong?