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

carbon根据指定格式输出时间字符串有问题 #73

Closed
YuXiaoCoder opened this issue Jul 22, 2021 · 2 comments
Closed

carbon根据指定格式输出时间字符串有问题 #73

YuXiaoCoder opened this issue Jul 22, 2021 · 2 comments
Labels
Wontfix Indicates that work won't continue on an issue, pull request, or discussion

Comments

@YuXiaoCoder
Copy link

carbon version: 1.3.9 or 1.4.2

dataTime := carbon.Now().ToFormatString("Mon, 02 Jan 2006 15:04:05 GMT")
fmt.Println(dataTime)
output: Julo7, 02 Jpm7 2006 15:04:05 17JulCST

dataTime = time.Now().Format("Mon, 02 Jan 2006 15:04:05 GMT")
fmt.Println(dataTime)
output: Thu, 22 Jul 2021 17:45:54 GMT

@gouguoyin
Copy link
Member

ToFormatString()方法用错了,该方法支持的格式是Y-m-d H:i:s这样的字符,所有支持的字符请查看格式化符号表
"Mon, 02 Jan 2006 15:04:05 GMT"明显是一个RFC7231格式,可以用carbon.Now().ToRfc7231String()

@gouguoyin
Copy link
Member

v1.4.4版本中还可以使用carbon.Now().Layout("Mon, 02 Jan 2006 15:04:05 GMT")

@gouguoyin gouguoyin added invalid Wontfix Indicates that work won't continue on an issue, pull request, or discussion labels Jul 24, 2021
@gouguoyin gouguoyin reopened this May 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Wontfix Indicates that work won't continue on an issue, pull request, or discussion
Development

No branches or pull requests

2 participants