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

String Type Unix timestamp support #1150

Closed
lqzhgood opened this issue Oct 19, 2020 · 4 comments
Closed

String Type Unix timestamp support #1150

lqzhgood opened this issue Oct 19, 2020 · 4 comments

Comments

@lqzhgood
Copy link

Describe the bug

dayjs("1564482923186").format('YYYY-MM-DD') ==> "1567-12-29" ❌
dayjs(1564482923186).format('YYYY-MM-DD') ==> "2019-07-30"  ✔️

Expected behavior

dayjs("1564482923186").format('YYYY-MM-DD') ==>  "2019-07-30"  ✔️

Information

  • Day.js Version 1.9.3
  • OS: Windows
  • Browser Chrome 86
  • Time zone: UTC+08:00
@iamkun
Copy link
Owner

iamkun commented Oct 20, 2020

a unit timestamp is always a Number not a String

@lqzhgood
Copy link
Author

lqzhgood commented Oct 20, 2020

I know that timestamps are numeric, and supporting this will be stronger.

Or for this kind of obvious error, error should be reported directly instead of giving an error value.

like new Date("1564482923186") ==> Invalid Date

###################################
我知道时间戳是数字类型,支持这个会更强壮吧。
或者对于这种 明显 的错误, 直接报错可能比给出一个错误的值更好。
类似于 new Date("1564482923186") ==> Invalid Date

@iamkun
Copy link
Owner

iamkun commented Oct 20, 2020

Ture, we can add this as a special plugin

@iamkun iamkun closed this as completed Oct 20, 2020
@iamkun
Copy link
Owner

iamkun commented Oct 23, 2020

Added in #1163

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

No branches or pull requests

2 participants