*Note generate date and year as eg:1209
function GenerateAutoNumYYMM() {
var newvalueMonth;
var d = new Date(); //Today Date
var valueMonth = new Date().getMonth() + 1; //Value month need to +1
var valueYear = new Date().getFullYear();
var valueYearLength = valueYear.toString().length; //Get the length
var YearToString = valueYear.toString(); //Convert to string
var last_char=YearToString.charAt(valueYearLength-1); //Get last character
var Before_last_char=YearToString.charAt(valueYearLength-2); //Get last second character
var LastTwoYearChar = Before_last_char + last_char; //Get last two character
var valueMonthLength = valueMonth.toString().length; //get month length
if (valueMonthLength != 2) {
newvalueMonth = "0" + valueMonth.toString(); //Convert to string
}
else {
newvalueMonth = valueMonth.toString(); //Convert to string
}
var NewYYMM = LastTwoYearChar + newvalueMonth; //Combine both month and year
//Eg. Year 2012 month 9
return NewYYMM; //Answer 1209
}
The reason why im doing this because it is needed for auto numbering year format. Requested in other way.
0 comments:
Post a Comment