Link to home
Start Free TrialLog in
Avatar of Neil Thompson
Neil ThompsonFlag for United Kingdom of Great Britain and Northern Ireland

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
Avatar of Rainer Jeschor
Rainer Jeschor
Flag of Germany image

Hi,
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
ASKER CERTIFIED SOLUTION
Avatar of Rainer Jeschor
Rainer Jeschor
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Neil Thompson

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?
180 days ago is December. That's half a year. 90 days would be February.
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 :)
Many thanks all for your example and comments :) Saved me hours!