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

dayjs not work in safari #254

Closed
wukong1995 opened this issue Jun 25, 2018 · 17 comments
Closed

dayjs not work in safari #254

wukong1995 opened this issue Jun 25, 2018 · 17 comments
Labels
☢️Bug Something isn't working released

Comments

@wukong1995
Copy link

dayjs('2018-03-27').format('D')

in chrome: it is work and it show 27
in safari: it is not work and it show NaN

@iamkun
Copy link
Owner

iamkun commented Jun 25, 2018

@wukong1995 Tested on my Mac safari and works fine. And further information you could supply?

dayjs('2018-03-27').format('D')

@wukong1995
Copy link
Author

wukong1995 commented Jun 26, 2018

@iamkun I debug and find the error.

dayjs('2018-03-27 11:49').format('YYYY-MM-DD')

in chrome: it show 2018-03-27
in safari: it show NaN-NaN-NaN

@iamkun
Copy link
Owner

iamkun commented Jun 26, 2018

@wukong1995 try dayjs('2018-03-27 11:49:00') first. And I'll check this bug later.

@iamkun iamkun added the ☢️Bug Something isn't working label Jun 26, 2018
@artiely
Copy link

artiely commented Jun 27, 2018

try dayjs('2018-03-27 11:49', 'YYYY-MM-DD').format('YYYY-MM-DD')

@JZLeung
Copy link

JZLeung commented Aug 23, 2018

I use this to be compatible with ios.

// util.js
import dayjs from 'dayjs'

const _dayjs = (date, c) => {
  if (typeof date === 'string') date = date.replace(/-/g, '/')
  return dayjs(date, c)
}

export default _dayjs

in safari, new Date('2018-08-23 11:12') will return Invalid Date.

use 2018/08/23 11:12 instead.

@ycshill
Copy link

ycshill commented Sep 12, 2018

I think you should fix the code to support the way like this writing.

@hammadzz
Copy link

hammadzz commented Oct 16, 2018

This is clearly a problem. The fix suggested works but is hacky. This should be taken as a major bug. I am considering switching back to momentjs.

I see this same issue on mobile react-native Android but works fine on iOS

@alancwoo
Copy link

This is also a problem in Firefox, as of 62.0b20 on OS X 10.14.1.

I had to fix it by changing all my date formats to Y/m/d

@brianbolnick
Copy link

From my testing it only works in chrome and opera. Edge/IE, firefox, safari are all broken.

@iamkun iamkun closed this as completed in e02ae82 Feb 4, 2019
iamkun pushed a commit that referenced this issue Feb 4, 2019
## [1.8.3](v1.8.2...v1.8.3) (2019-02-04)

### Bug Fixes

* fix ios safari YYYY-MM-DD HH:mm parse BUG ([e02ae82](e02ae82)), closes [#254](#254)
@iamkun
Copy link
Owner

iamkun commented Feb 4, 2019

🎉 This issue has been resolved in version 1.8.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

@iamkun iamkun added the released label Feb 4, 2019
@davidfurlong
Copy link
Contributor

I can confirm this resolved the issues we were seeing in Chrome & Safari on OSX (not windows)

@eric-personal
Copy link

eric-personal commented Feb 26, 2019

This is still not working in safari. dayjs('2019-02-28T19:05:00+0000') is still returning null in Safari.
I'm on "dayjs": "^1.8.8",

@ghost
Copy link

ghost commented Feb 26, 2019

@eric-personal
Check my comment here
#73 (comment)

andrewhood125ruhuc added a commit to andrewhood125ruhuc/SidRH2 that referenced this issue May 10, 2022
## [1.8.3](iamkun/dayjs@v1.8.2...v1.8.3) (2019-02-04)

### Bug Fixes

* fix ios safari YYYY-MM-DD HH:mm parse BUG ([e02ae82](iamkun/dayjs@e02ae82)), closes [#254](iamkun/dayjs#254)
andrewhood125ruhuc added a commit to andrewhood125ruhuc/SidRH2 that referenced this issue May 10, 2022
## [1.8.3](iamkun/dayjs@v1.8.2...v1.8.3) (2019-02-04)

### Bug Fixes

* fix ios safari YYYY-MM-DD HH:mm parse BUG ([e02ae82](iamkun/dayjs@e02ae82)), closes [#254](iamkun/dayjs#254)
@wisammechano
Copy link

wisammechano commented Feb 14, 2023

dayjs("Feb 2023") is not working on safari while works well on chrome. Is this usage not intended?

Update:
It seems new Date("Feb 2023") doesn't work on Safari but works on chrome. I expect dayjs to circumvent this though

@IonelLupu
Copy link

still an issue @iamkun :

dayjs('01/12/2024').format('MMM DD') - doesn't work in safari ONLY. But works in Chrome (both on macos)

dayjs('01-12-2024').format('MMM DD') - works in any browser and OS

Is dayJs getting some locale from safari and it then can't recognise dates with dashes in them?

@aaron-mota
Copy link

Still having an error in Safari doing various things with dayjs('YYYY-MM-DD'), have to use @JZLeung fix to make dayjs('YYYY/MM/DD'). "dayjs": "^1.11.7",

@Lazy-poet
Copy link

const _dayjs = (date, c) => {
  if (typeof date === 'string') date = date.replace(/-/g, '/')
  return dayjs(date, c)
}

export default _dayjs

you're a lifesaver

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
☢️Bug Something isn't working released
Projects
None yet
Development

No branches or pull requests