I’m attempting the “Booking up for Beauty” exercise. I’m getting stuck with Go unable to parse the date in the format I want.
01/02/2023 could be parsed into different values based on the format (01-FEB-2023 in DD/MM/YYYY format or 02-JAN-2023 in MM/DD/YYYY format). Other languages provide precise format strings to distinguish between the two formats.
Given that Go uses examples to parse the dates, how does Go distinguish between MM/DD/YYYY and DD/MM/YYYY formats ?
The time package provides date parsing with the Parse() function. It uses the time.Format to figure out how to parse the string. The format string must use the exact date time Jan 2, 03:04:05pm 2006 (date 01/02/06) to specify the format. To translate from other languages, use this replacement mapping: {%m => 1; %d => 2; %H => %3; %M => 4; %S => 5; %Y => 6}.