I using hexo blog system. I can't find a way to convert momentjs of hexo to jalali. How I cant convert the date to jalali calendar date ?
hexo use moment for date and time. For converting the Gregorian calendar to Jalali calendar in hexo first install moment-jalaali with npm or yarn. In your theme directory create a folder name it scripts and a js file put these line of codes on your file and save it. (this is a helper)
'use strict';
var moment = require('moment-jalaali');
hexo.extend.helper.register('jalaali', function (date) {
return moment(date).format('jMMMM jYYYY');
});
hexo.extend.helper.register('jalaaliyear', function (date) {
return moment(date).format('jYYYY');
});
you can use any format of date and time in .format()
.
after all if you want name of months in persian line فروردین easily put this line at the end of the created js file
moment.loadPersian()
How to use it? for example in posts:
<%- jalaali(item.date) %>