Golang cannot parse time

WBOY
Release: 2024-02-14 20:12:08
forward
922 people have browsed it

Golang cannot parse time

php editor Yuzai today will introduce to you the problem that Golang cannot parse time. When using Golang for time parsing, you sometimes encounter situations where the time cannot be parsed correctly, which may cause exceptions or wrong results in the program. This article will provide you with a detailed analysis of the causes and solutions to this problem, helping you better handle tasks related to time analysis. Let’s take a look!

Question content

I'm creating a go script that attempts to parse a datetime string.

My appointments come from my clients like

2023-01-31t10:44:59.800

I create a basic layout and try to parse it using time.parse

65bd96be05 bad

From this, I get an error that the time cannot be parsed.

I tried removing t from the datetime string but got the same output.

Does my layout need anything different? pm Maybe it doesn’t work?

I'm trying to solve the actual problem as the error is very vague

Workaround

Your parsed string needs to match your time format.

String "2006-01-02T15:04:05.000" Contains T, milliseconds, and omits "pm". It will then correctly parse the time as 2023-01-31 10:44:59.8 0000 UTC

Try it on the playground

The above is the detailed content of Golang cannot parse time. For more information, please follow other related articles on the PHP Chinese website!

source:stackoverflow.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template