dayjs icon indicating copy to clipboard operation
dayjs copied to clipboard

Format breaks on React Native

Open BalogunofAfrica opened this issue 3 years ago • 3 comments

Describe the bug

Dayjs breaks react native when I call the format method e.g:

import dayjs from "dayjs";

dayjs().format("ddd MMM D, YYYY")

I get this error:

undefined is not an object evaluating ('i[n]')

Expected behavior

Dayjs should format date e.g Wed Jul 27, 2022

Information

  • Day.js Version [e.g. v1.11.4]
  • OS: [iOS and Android]
  • Browser [e.g. chrome 62]
  • Time zone: [GMT+01:00 WAT]

BalogunofAfrica avatar Jul 27 '22 10:07 BalogunofAfrica

I think your code works fine, pls check the func which mention it ( or can you provide it here ) image image

AlfandaviAU avatar Jul 28 '22 04:07 AlfandaviAU

I use it to display a text like so

import dayjs from "dayjs";
...
<Text>dayjs(time?.dateTime).format("hh:mm A")</Text>
...

When I use moment, it doesn't break the app and the text is displayed

import moment from "moment";
...
<Text>moment(time?.dateTime).format("hh:mm A")</Text>
...

The value time is a prop I am receiving and it's always defined.

This is the error that gets thrown when I try to invoke dayjs:

dayjs error

BalogunofAfrica avatar Jul 29 '22 05:07 BalogunofAfrica

I created a demo CodeSandbox and it runs without error - strange 😄

BePo65 avatar Aug 04 '22 05:08 BePo65

Cross-referencing with:

https://github.com/iamkun/dayjs/issues/1377

Timezone support seems broken with React-Native Hermes/Intl. Has anyone got this to work?

ospfranco avatar Sep 23 '22 14:09 ospfranco