dromara / carbon

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

ParseByFormat not supported "U" format #206

Closed JKeita closed 11 months ago

JKeita commented 11 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 11 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 11 months ago

v2.3.1 has been released

gouguoyin commented 11 months ago
image