0

javascript code is

 var lastday = new Date(curr.setDate(curr.getDate() - curr.getDay() + 5));

I am getting output

Fri Oct 25 2013 17:15:12 GMT+0530 (India Standard Time)

The output is correct but i want output something like

25/10/2013

How can i get this?

Thanks

M Akela
  • 249
  • 5
  • 21

2 Answers2

3

You'll need to format the date object using the API:

var str = lastday.getDate() + "/" + (lastday.getMonth() + 1) + "/" + lastday.getFullYear();
Daniel
  • 3,726
  • 4
  • 26
  • 49
0

Yes, you can do it like:

var lastday = new Date(curr.setDate(curr.getDate() - curr.getDay() + 5));

var date = lastday.getDate();

// 1 is added since it's zero-based value 
// (where zero indicates the first month of the year).
var month = lastday.getMonth() + 1;      
var year = lastday.getFullYear();

// You can change the format to like 'dd/mm/yyyy' or 'mm/dd/yyyy'
// based on your requirements below
var newDate = date + '/' + month + '/' + year;


console.log(newDate); // 25/10/2013
palaѕн
  • 72,112
  • 17
  • 116
  • 136