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

Unable to override global format for FromNow #116

Open
kyliem29 opened this issue Jun 11, 2020 · 0 comments
Open

Unable to override global format for FromNow #116

kyliem29 opened this issue Jun 11, 2020 · 0 comments

Comments

@kyliem29
Copy link

In our app we have set the global format like this:

Moment.globalFormat = 'MM/DD/YYYY'

In our component we are trying to use fromNow:

<Moment fromNow>2020-06-11T22:00:00.000Z</Moment>

However this displays '06/12/2020' instead of '1 hour ago'.

Expected behaviour:
'1 hour ago'

Actual behaviour:
'06/12/2020'

Is it possible to override the global format for fromNow?
I believe global format should not be applied to fromNow as the format is determined by the locale.

I have tried the following but none of them work:
<Moment fromNow format={null}>2020-06-11T22:00:00.000Z</Moment>
<Moment fromNow format="">2020-06-11T22:00:00.000Z</Moment>

Current workaround is to remove the global format setting and it then fromNow works, however we have to set the format on every other instance of Moment.

Additional information:

  • package version 0.9.7
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

1 participant