I am using Babakhani
Datepicker
and actually i have done substract
thing from datepicker
but it does not work on this , so i want to cast -7
days from currentdate
I have done it on console
Like this
var nowDate = new Date();
var days = 7;
nowDate.setDate(nowDate.getDate() - days);
var mamat = nowDate.toISOString().split('T')[0];
console.log(mamat);
but as i am using PERSIAN
not GREGORIAN
i cant convert it
I have to use it on this
$(".persianDate").pDatepicker();
today date is 1/13/2019
and i want it to be 1/7/2019
Babakhani
Source :
http://babakhani.github.io/PersianWebToolkit/doc/datepicker/options/
let date = new Date();
date.setDate(date.getDate()-1);
console.log(date.toLocaleDateString());
// Woud log:
// 1/12/2019
console.log(date.toLocaleDateString('fa-IR'));
// Woud log:
// ۱۳۹۷/۱۰/۲۲
If you want to set the calendar, then you can pass the desired calendar as an argument to the toLocaleDateString method, as per the MDN docs. For example, passing 'ar-EG' will result in Arabic digits.
Possible duplicate of Subtract days from a date in JavaScript.