Javascript JDate Class ;)

new Date()

Now with new Date() creates a new gregorian and jalali date object with the current date and time:

                    
                        var date = new Date();
                        console.log( date.echoFa() );
                        console.log( date.echo() );
                        console.log( date );
                    
                

new JDate(...).echo

                    
                        var date = new Date(2019, 4, 3, 10, 33, 30, 0);
                        console.log( date.echoFa("l، j F Y - H:i:s") );
                        console.log( date.echo("l، j F Y - H:i:s") );
                    
                
Character Description Range Example
aBefore noon and afternoonق.ظ - ب.ظق.ظ
bNumeric representation of a season, without leading zeros0-31
dDay of the month, 2 digits with leading zeros01-3113
fSeason nameبهار-زمستانبهار
g12-hour format of an hour without leading zeros0-1211
h12-hour format of an hour with leading zeros00-1203
iMinutes with leading zeros00-5913
jDay of the month without leading zeros1-314
lA full textual representation of the day of the weekشنبه-جمعهیکشنبه
mNumeric representation of a month, with leading zeros01-1202
nNumeric representation of a month, without leading zeros1-122
sSeconds, with leading zeros00-5903
tNumber of days in the given month0-3128
uMillisecond00000028
vShort year display in lettersیک-نهصد و نود و نهنود و هشت | چهارصد و دو
wNumeric representation of the day of the week0-66
yA two or three digit representation of a year1-99998 | 402
ABefore noon and afternoonبعد از ظهر - قبل از ظهرقبل از ظهر
DPersian ordinal suffix for the day of the month, 2 charactersشن‍ - جم‍سه
FA full textual representation of a monthفروردین - اسفنداردیبهشت
G24-hour format of an hour without leading zeros0-243
H24-hour format of an hour with leading zeros00-2403
JDay of the monthیک-سی و یکسیزده
LWhether it’s a leap year0-11
MA short textual representation of a month, two lettersفر-اس‍ار
ODifference to Greenwich time (GMT) in hours-1200 - +1400+0330
VFull year display in lettersصفر-...یک هزار و سیصد و نود و هشت
YA full numeric representation of a year, 4 digits0-...1398

JDate.parse(...)

You can parse specified shamsi or gregorian date from valid date string to convert it to milliseconds.

                    
                        Date.parseJalali("1399")
                        Date.parseJalali("1399/02")
                        Date.parseJalali("1399/02/13")
                        Date.parseJalali("1399/02/13 03:14:30")
                        Date.parseJalali("2019/05/03 01:02:03")
                        new Date(
                          Date.parseJalali("1993/05/03 03:01:03")
                        ).echoFa("Y/m/d - H:i:s")
                    
                

Get Jalali Date Methods

These methods can be used for getting information from a date object as a jalali date:

Method Description
getJalaliDate()Get the day as a number (1-31)
getJalaliDay()Get the weekday as a number (0-6)
getJalaliFullYear()Get the year as a four digit number (yyyy)
getJalaliShortYear()Get the year as a two or three digit number (yy | yyy)
getHours()Get the hour (0-23)
getMilliseconds()Get the millisecond (0-999)
getMinutes()Get the minute (0-59)
getJalaliMonth()Get the month as a number (0-11)
getSeconds()Get the second (0-59)
getTime()Get the time (milliseconds)
getTimezone()Difference to Greenwich time (GMT) in hours
getTimezoneOffset()Difference between UTC and Local Time
isJalaliLeapYear()Whether it’s a leap year (0-1)

Set Jalali Date Methods

These methods can be used for set jalali date values (years, months, days, hours, minutes, seconds, milliseconds) for a date object:

Method Description
setJalali(year, [month, date, hours, minutes, seconds])Set jalali date
setHours(hours, min, sec, ms)Set the hour (0-23)
setMilliseconds(ms)Set the milliseconds (0-999)
setMinutes(min, sec, ms)Set the minutes (0-59)
setSeconds(sec, ms)Set the seconds (0-59)
setTime(ms)Set the time (milliseconds)