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?
Asked
Active
Viewed 1,424 times
2
-
have you see https://momentjs.com/ ? this might help you – Dacre Denny Oct 15 '18 at 23:18
-
2Possible duplicate of [How do you convert a Unix timestamp to Jalali/Shamsi/Persian format?](https://stackoverflow.com/questions/43850436/how-do-you-convert-a-unix-timestamp-to-jalali-shamsi-persian-format) – Paul Maxwell Oct 16 '18 at 00:38
-
@DacreDenny yea that definitely helped me thanks for the answer – sina farbod Oct 17 '18 at 21:47
-
I've found and used an useful package `https://github.com/webilix/jalali-date-time#readme` that can convert UTC time and date to Persian and other locale. – Mahmonir Bakhtiyari Jun 10 '21 at 18:19
3 Answers
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)

Ehsan Paknejad
- 154
- 1
- 7