In my application, there is a calendar feature that displays a string representation of a timestamp. When selecting a date from a date picker (using date-fns and angular-calendar), I make a POST request 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);
}
I use a utility function because formatTime() has issues with 12/24h representation. However, I noticed a strange behavior where the same date (let's say July 2nd) outputs differently when running in debug mode - 2022-07-02T09:00:00.000+00:00
versus running with ng serve - 2022-02-07T09:00:00.000+00:00
.
You can observe this discrepancy in the console screenshots:
https://i.sstatic.net/gsAhj.png
https://i.sstatic.net/Sxp5B.png
The error highlighted in the first screenshot showing the 15th month (July) indicates a failure due to incorrect formatting. I suspect that there may be an issue with the locale settings, but what could it be? What am I overlooking here?
Thank you for your time.