Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
95 views
in Technique[技术] by (71.8m points)

How to get the time difference in react native

Is there any React-native library that helps getting the difference between two dates. I mean like the following.

Example

question from:https://stackoverflow.com/questions/65920454/how-to-get-the-time-difference-in-react-native

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

try using moment

import moment from 'moment';
 {
                moment(date, 'YYYY-MM-DD')
                  .month(0)
                  .from(moment().month(0))
}

'YYYY-MM-DD' can be whatever format

this one is getting me the difference between the given date and now

here you can find documentation https://momentjs.com/docs/

and here more libraries https://blog.logrocket.com/4-alternatives-to-moment-js-for-internationalizing-dates/


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...