fingerpich / jalali-moment

Display, parse, manipulate, validate and convert jalali (Persian, Khorshidi, Shamsi) or Gregorian (Miladi) dates and times.
https://fingerpich.github.io/jalali-moment/
MIT License
436 stars 68 forks source link

unix date converting return invalid value for some dates #46

Closed seyyed-sina closed 6 years ago

seyyed-sina commented 6 years ago

I want to convert birthday input to unix timestamp. The problem is that it converts to invalid Unix timestamp when I enter birthYear for example '1331'.

Here's my code:

const birthDateInput =`${birthObj.birthYear}/${birthObj.birthMonth}/${birthObj.birthDay}`;
const birthdate = Moment(birthDateInput, 'jYYYY/jM/jD').format('X');

The result for '1331/2/13' is: -557465400

fingerpich commented 6 years ago

Hi, Sorry for delay, As you know timestamp is the number of seconds between a particular date and January 1st, 1970 and 1331/2/13 in Gregorian is 1952/05/03 so the timestamp has to be negative and I think -557465400 is OK.