Reputation: 497
I want to convert linux timestamp like (1538522020) to jalali/shamsi date time like (11/7/1397). how can I convert these times to each other?
Upvotes: 2
Views: 1793
Reputation: 698
No need to install a module. Use this pure javascript code: (The performance and speed are much better)
https://stackoverflow.com/a/55071513/16212595
Upvotes: 0
Reputation: 3325
I used https://github.com/jalaali/jalaali-js and it worked like a charm
npm install --save jalaali-js
In your code:
var jalaali = require('jalaali-js')
jalaali.toJalaali(new Date(JS Date Object which could be a timestamp))
Upvotes: 2
Reputation: 497
finaly I have found the answer, just used: https://www.npmjs.com/package/moment-jalaali package to convert it to jalali/persian date in render method:
import jMoment from 'moment-jalaali-react-native-calendar';
and in render method: const jdatetime = jMoment.unix(time).format('d jMMMM jYYYY');
Upvotes: 1