ezdate: a jQuery plugin
The easiest and the best way to convert dates to persian date.
ezdate is a 1 KB (gzipped, minfied) jquery function that converts dates in your website automatically to persian date.
Usage
First, load jQuery and the plugin:
Now, let's attach it to your timestamps on DOM ready - put this in the head section:
This will turn all <time>
elements with a class of ezdate
and a
datetime
attribute:
October 18, 1993
into something like this:
26/7/1372
Options
persianNumber
(default: false
)
;
Turns:
October 18, 1993
into
۲۶/۷/۱۳۷۲
attrName
(default: 'data-datetime'
)
Date source attribute. It's recommended to use data-datetime
for ezdate as it's HTML5 friendly too.
dateFormat
(default: D/M/YYYY
)
You can use your custom date format to show.
Some examples:
Value | Meaning |
---|---|
D/M/YYYY |
26/7/1372 |
D/MM/YYYY |
26/07/1372 |
DD/MMM/YYYY |
26/مهر/1372 |
ezdate also calls complete
function when finished its job as callback.
Enjoy using ezdate!