Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

时间格式能否支持go time库的时间格式 #127

Closed
duxphp opened this issue Apr 23, 2022 · 2 comments
Closed

时间格式能否支持go time库的时间格式 #127

duxphp opened this issue Apr 23, 2022 · 2 comments

Comments

@duxphp
Copy link

duxphp commented Apr 23, 2022

时间格式能否安装go time库的时间格式,不然记忆会有问题 标准库的 2006-01-02 15:04:05 遵循了 1 2 3 4 5 6 进行排列便于记忆 carbon 的 2020-08-05 13:14:15 遵循的是那种规则呢 或者可以兼容两种格式

@duxphp duxphp changed the title 时间格式能否安装go time库的时间格式 时间格式能否支持go time库的时间格式 Apr 23, 2022
@gouguoyin
Copy link
Member

gouguoyin commented Apr 23, 2022

ParseByLayout()方法可以支持go time库时间格式的解析

carbon.ParseByLayout("2020|08|05 13|14|15", "2006|01|02 15|04|05").ToDateTimeString() // 2020-08-05 13:14:15

也可以像PHP一样使用Ymd之类的格式

carbon.ParseByFormat("2020|08|05 13|14|15", "Y|m|d H|i|s").ToDateTimeString() // 2020-08-05 13:14:15

@gouguoyin
Copy link
Member

2020-08-05 13:14:15 不是格式,而是需要解析的示例日期

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants