var date = '04/04';<br>
alert(new Date(date));<br>
//now year 2013<br>
//result Wed Apr 04 <b>2001</b>
I want
//result Wed Apr 04 <b>2013</b>
var date = '04/04';<br>
alert(new Date(date));<br>
//now year 2013<br>
//result Wed Apr 04 <b>2001</b>
I want
//result Wed Apr 04 <b>2013</b>
 
    
     
    
    You can get the current date by new Date(); So current year can be found by:
var currentDate = new Date();
  //this would return 2013
So following code would do the work for getting correct date:
var currentDate = new Date();
var currentYear = currentDate.getFullYear();
var date = "04/04";              //the date entered
var comp = date.split('/');
var m = parseInt(comp[0], 10);   //this would give you the entered month
var d = parseInt(comp[1], 10);   //this would give you the entered date
var correctDate = new Date(currentYear, m - 1, d);
correctDate.toDateString();   //this line will return the date
Hope it helps.
 
    
    Set the parts individually with the setX() functions.
 
    
     
    
    var nowYear=new Date().getFullYear(); //current year
var date = '04/04/'+nowYear.toString();
alert( new Date(date));
is that really returning Wed Apr 04 2001? instead of invalid date? without year in string , how did it get parsed?
var date = '04/04';
date = new Date(date);
date = new Date(2013, date.getMonth(), date.getDate());
alert(date);
 
    
    With static year it will be:
var date = '04/04';
alert(new Date('2013/'+date));
where date format is yyyy/MM/dd
