Expiry Date
I have two text fields, one where the user will enter the date of manufacture (dd-mmmm-yyyy) whilst the other one is for Expiry date (mmmm-yyyy), which has to be calculated manually.
The expiry date is by default 2 years. If date of manufacture is between 1 - 14 day of the month, expiry has to be the previous month (E.g, Date of manufacture: 05 July 2016; Exp: June 2018 || Date of manufacture: 25 July 2016; Exp: July 2018).
I have found a code to add a number of days however I have an issue with the leap year. Can someone provide me with a code? I am new to JavaScript and have no experience.
Script is as follows:
var strStart = this.getField("DateStart").value;
if(strStart.length)
{
var dateStart = util.scand("dd mmmm yyyy",strStart);
var oneDay = 24 * 60 * 60 * 1000;
var dueMillis = dateStart.getTime() + 716 * oneDay;
var dueDate = new Date(dueMillis);
event.value = util.printd("mmmm yyyy",dueDate);
}
else
event.value = "N/A";
