Conversion

To String 1.0.0+

                
let p = new PersianDate('1399/1/1','jalali');

p.toString('jYY-jM-jD'); // 99-1-1

p.toString('YY M D');    // 20 3 20

p.toString('`The month of date is:` jMMMM');      // The month of date is: فروردین

p.calendar('jalali').toString('?YY-?M-?D');       // 99-1-1

p.calendar('gregorian').toString('?YY-?M-?D');    // 20-3-20
                
        

1. When you use the question mark ("?"), if calendar equal to 'jalali', replaces with 'j' letter.

2. You can see all of the formats in here!

The default format of toString method is 'date'

To Array 1.5.0+

                
let p = new PersianDate('1399/1/1','jalali');

p.toArray(); // [1399, 1, 1, 0, 0, 0, 0] --> [year, month, date, hour, minute, second, millisecond]
                
        

You can use the other formats in the array

                
p.toArray(['jYY', 'jMM', 'jDD', 'hh', 'mm', 'ss', 'CCCC']); // ['99', '01', '01', '00', '00', '00', '000']
                
        

To Object 1.3.0+

                
let p = new PersianDate('1399/1/1','jalali');

p.toObject(); // { year: 1399, month: 1, date: 1, hour: 0, minute: 0, second: 0, millisecond: 0 }
                
        

You can use the other formats in the object

                
p.toObject({ y: 'jYY', M: 'jMM', d: 'jDD', h: 'hh', m: 'mm', s: 'ss', ms: 'CCCC' });

// { year: '99', month: '01', date: '01', hour: '00', minute: '00', second: '00', millisecond: '000' }
                
        

To Date (Javascript Date) 2.0.0+

get the Javascript native Date instance.

                
let p = new PersianDate('2020/1/1');

let date = p.toDate(); // new Date(2020,0,1)