2

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?

curveball
  • 4,320
  • 15
  • 39
  • 49
sina farbod
  • 497
  • 4
  • 17

3 Answers3

2

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))
Mahgolsadat Fathi
  • 3,107
  • 4
  • 16
  • 34
1

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');

sina farbod
  • 497
  • 4
  • 17
0

No need to install a module. Use this pure javascript code: (The performance and speed are much better)

https://stackoverflow.com/a/55071513/16212595

Ehsan Paknejad
  • 154
  • 1
  • 7