how to get next year -1 day

287 views
Skip to first unread message

uneuronh

unread,
Apr 26, 2011, 2:42:12 PM4/26/11
to Datejs - A JavaScript Date Library
Hi,

I have customers entering a date say 01/04/2011 ( dd/mm/yyyy)
I have to find the 1 year date from the entered date -1 day
i.e,
if date is 01/04/2011(dd/mm/yyy)
output should be 31/03/2012(dd/mm/yyyy)

I tried

ed = new Date.parseExact(dateText, "dd/mm/yyyy");
ed.next().year();
alert(ed.toString("dd/mm/yyyy"));

This adds one year to the entered date ie, 01/04/2012

if i do ed.add(-1).day(); the output is 31/04/2012 instead of
31/03/2012(dd/mm/yyyy)

Can anyone let me know, if there is work around

Thanks,
Umesh
Reply all
Reply to author
Forward
0 new messages