Neil Thompson
asked on
using jQuery 2 create 2 dates, 1 now in DD/MM/YYYY format, the 2nd same format but 180 days ago
Hi
This seems such an easy thing to do bit having difficulty finding an example.
using jQuery I want to create 2 dates, 1 now in DD/MM/YYYY format, the 2nd same format but 180 days ago and assign them to variable to be used later.
Need to take into account that for example on 30 Jan 2015 then -180 days would take it back to 2014 etc.
Thanks
Neil
This seems such an easy thing to do bit having difficulty finding an example.
using jQuery I want to create 2 dates, 1 now in DD/MM/YYYY format, the 2nd same format but 180 days ago and assign them to variable to be used later.
Need to take into account that for example on 30 Jan 2015 then -180 days would take it back to 2014 etc.
Thanks
Neil
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Rainer
Thats brilliant but the 2nd date is wrong for some reason, 01/12/2014
Should be around 30/02/2015
Any ideas?
Thats brilliant but the 2nd date is wrong for some reason, 01/12/2014
Should be around 30/02/2015
Any ideas?
180 days ago is December. That's half a year. 90 days would be February.
ASKER
lol, embarrassingly dumb , apologies :)
Nope, done it myself! *grin* you can look at days and numbers too long sometimes!
Btw don't give me any points if you were thinking along those lines... Rainer has more than answered your question without my help :)
Btw don't give me any points if you were thinking along those lines... Rainer has more than answered your question without my help :)
ASKER
Many thanks all for your example and comments :) Saved me hours!
for this I would recommend the library moment.js
http://momentjs.com
There you can format the output as well as adding/subtracting days/months ...
HTH
Rainer