I have to add a javascript calendar in my website..but the date format is mm/dd/yy. I want to change it to yy/mm/dd. I had changed the function function f_tcalGenerDate()
but i got the error invalid date format..How to change the format using this code??
function f_tcalParseDate (s_date) {
var re_date = /^\s*(\d{1,2})\/(\d{1,2})\/(\d{2,4})\s*$/;
if (!re_date.exec(s_date))
return alert ("Invalid date: '" + s_date + "'.\nAccepted format is yyyy/mm/dd.")
var n_day = Number(RegExp.$2),
n_month = Number(RegExp.$1),
n_year = Number(RegExp.$3);
if (n_year < 100)
n_year += (n_year < this.a_tpl.centyear ? 2000 : 1900);
if (n_month < 1 || n_month > 12)
return alert ("Invalid month value: '" + n_month + "'.\nAllowed range is 01-12.");
var d_numdays = new Date(n_year, n_month, 0);
if (n_day > d_numdays.getDate())
return alert("Invalid day of month value: '" + n_day + "'.\nAllowed range for selected month is 01 - " + d_numdays.getDate() + ".");
return new Date (n_year, n_month - 1, n_day);
}
// date generating function
function f_tcalGenerDate (d_date) {
return (
(d_date.getMonth() < 9 ? '0' : '') + (d_date.getMonth() + 1) + "/"
+ (d_date.getDate() < 10 ? '0' : '') + d_date.getDate() + "/"
+ d_date.getFullYear()
);
}