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

"2023-11-08T09:52:48" not support? #202

Closed
zsq1234 opened this issue Nov 23, 2023 · 5 comments
Closed

"2023-11-08T09:52:48" not support? #202

zsq1234 opened this issue Nov 23, 2023 · 5 comments
Labels
Question Indicates that an issue, pull request, or discussion needs more information

Comments

@zsq1234
Copy link

zsq1234 commented Nov 23, 2023

图片

use:carbon.Parse(v).ToStdTime().UnixMilli()
v is "2023-11-08T09:52:48"
but get value 18446681938112751616

i find the layouts not contain this format, why or can support it?very thank you
图片

@zsq1234 zsq1234 added the Question Indicates that an issue, pull request, or discussion needs more information label Nov 23, 2023
@gouguoyin
Copy link
Collaborator

The next version will be added. Currently, you can use ParseByLayout method

carbon.ParseByLayout("2023-11-08T09:52:48", "2006-01-02T15:04:05")

@gouguoyin
Copy link
Collaborator

gouguoyin commented Nov 23, 2023

In addition, you can replace

carbon.Parse(v.(string)).ToStdTime().UnixMilli()

with

carbon.Parse(v.(string)).TimestampMilli()

@zsq1234
Copy link
Author

zsq1234 commented Nov 23, 2023

thank you, i will try it.

i now meet question again, "2023-11-18T03:55:27.000+0000"
图片
and i do just like this, but get 0, how can i do with it?
图片

The next version will be added. Currently, you can use ParseByLayout method

carbon.ParseByLayout("2023-11-08T09:52:48", "2006-01-02T15:04:05")

@gouguoyin
Copy link
Collaborator

gouguoyin commented Nov 24, 2023

-0700 is a fixed format

carbon.ParseByLayout("2023-11-18T03:55:27.000+0000", "2006-01-02T15:04:05.999-0700").TimestampMilli()   // 1700279727000

@zsq1234
Copy link
Author

zsq1234 commented Nov 24, 2023

Thank you, this solved my problem

@zsq1234 zsq1234 closed this as completed Nov 24, 2023
gouguoyin added a commit that referenced this issue Nov 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question Indicates that an issue, pull request, or discussion needs more information
Projects
None yet
Development

No branches or pull requests

2 participants