dromara / carbon

A simple, semantic and developer-friendly golang package for time
https://pkg.go.dev/github.com/golang-module/carbon/v2
MIT License
4.77k stars 238 forks source link

ParseByFormat not supported "U" format #206

Closed JKeita closed 10 months ago

JKeita commented 10 months ago

Hello,

I encountered an issue with the following code:

t := c.ParseByFormat("1699677240", "U").Timestamp()
fmt.Println(t)

golang version: 1.21

carbon version: v2.2.14 time zone:PRC

I expected to get:

1699677240

But I actually get:

0

Thanks!

gouguoyin commented 10 months ago

It will fix in next version, currently you can use the following method:

t := c.CreateFromTimestamp(1699677240).Timestamp()
fmt.Println(t) // 1699677240
gouguoyin commented 10 months ago

v2.3.1 has been released

gouguoyin commented 10 months ago
image