Skip to content

Unable to override global format for FromNow #116

@kylie-marshall

Description

@kylie-marshall

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions