/JSJdate

Jalali (Shamsi) Date in Javascript

Primary LanguageJavaScriptThe UnlicenseUnlicense

JSJdate

Jalali (Shamsi) Date in Javascript

Really small (only 2KB) and accurate converter

Usage

without parameters : (returns Now)

JDate().toString()	//--> "1393/2/27"
JDate().getRooz()	//--> "جمعه"
JDate().getMah()	//--> "اردیبهشت"
JDate().getDate()	//--> 27
JDate().getMonth()	//--> 2
JDate().getYear()	//--> 1393

With a String Miladi Date:

JDate("2010/5/5").toString()	//--> "1389/2/15"

With a TimeStamp:

JDate(1273001400000).toString()	//--> "1389/2/15"

With a JSDate Object:

JDate(new Date("2010/5/5")).toString()	//--> "1389/2/15"

With a Relative date:

JDate('+5d').toString()	//--> "1393/3/1" (today + 5 days)
JDate('-5d').toString()	//--> "1393/2/22" (today - 5 days)

Include

to use with NodeJS just copy the object (19 lines) into your code to use in browser include the tarikh.js file in your page

 <script src="./tarikh.js"></script>