I used the link below for convert Jalali to Gregorian:
I receive data from user as string. And this is the code I use:
<script>
var jj = document.getElementById("fromDate1"),
bb = document.getElementById("showMe"),
splitOb, yy, mm, dd;
bb.onclick = function () {
splitOb = jj.value.split("/");
for (var i = 0; i < splitOb.length; i++) {
yy = splitOb[0];
mm = splitOb[1];
dd = splitOb[2];
}
var xx = yy.trim().toString(), nn = mm.trim().toString(), mmm = dd.trim().toString();
var xxx = parseInt(xx, 10);
var nnn = parseInt(nn, 10);
var mjj = parseInt(mmm, 10);
var hello = toGregorian(xxx, nnn, mjj);
alert(hello.gy + "/" + hello.gm + "/" + hello.gd);
/* var gh= "1395";
var ghh = parseInt(gh);
alert(ghh);*/
};
</script>
I used parseInt in my code and unfortunately the result is Nan, I checked my variables, all of them was strings. But when I convert them from string to integer the result is NaN too. when I set string to my variables manually like this code:
var jjj = "1395";
var yyyt = "05";
var kik = "04";
var xxx = parseInt(jjj, 10);
var nnn = parseInt(yyyt, 10);
var mjj = parseInt(kik, 10);
var hello = toGregorian(xxx, nnn, mjj);
alert(hello.gy + "/" + hello.gm + "/" + hello.gd);
Everything works fine, why?