Parse date string with comma

Hi,

I’m trying to parse a date string that looks like: 2019-08-09T01:02:03,444 however I don’t seem to be able to create a layout using the standard format, e.g. “2006-01-02T15:04:05,000”, with a comma. I appear to only be able to use a “.” (dot) to separate the milliseconds from the seconds. If I use a “.” in the layout and replace the “,” in the time string with a “.” using strings.Replace() all is well.

Am I missing something?

Thanks,

Rob

1 Like

Hi. No you are not missing anything. Go can’t handle floating point numbers with a comma instead of a dot. This example is trivial but what about 123,456 is it a float with three decimals (Sweden for example ) or a integer with six digits (USA for example)

2 Likes

Hi Johan,

Yeah, I lived in Germany, so seeing numbers like: 123.456,789 don’t bother me. I guess my issue is that I’m used to strptime() from Python which allows using formatting. So it seemed odd to me that I couldn’t say, “hey, use a comma to separate the seconds from the fractions of a second.” For now, I guess I’ll just replace the “,” with a “.” and be done with it.

Thanks,

Rob

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.