I have an application with a calendar that posts a string representation of a timestamp. I pick a date, let's assume from a date picker (it's date-fns and angular-calendar).
I have a POST in my service
postWorkingSlot(workingSlot: NewWorkingSlot, selectedOperativeID: number)
{
let util = new Util();
workingSlot.starting_time = util.formatDateString(workingSlot.starting_time)
workingSlot.ending_time = util.formatDateString(workingSlot.ending_time)
const body = JSON.stringify(workingSlot);
console.log('Timestamp added : ', body);
return this.http.post((endpoint + "/" + "api/v1/professional/availability_slot/" + selectedOperativeID ), body, this.httpOptions);
}
and this is a utility function I am using because I realised that formatDate() has some problems with 12/24h representation.
The weird thing is that for the same date (lets assume the 2nd of July) when I run in debug mode I am getting : 2022-07-02T09:00:00.000+00:00
and when I run with ng serve I am getting 2022-02-07T09:00:00.000+00:00
.
You can see this happening in console in the following 2 images :
The failure you can see in the first image is 7th of the 15th month (which of course fails). I suspect a problem in the locale settings but what? What am I missing?
Thanks a lot for your time.