Page 1 of 1

Scripting the date

Posted: Fri Mar 22, 2019 11:27 pm
by apietrocini
Hello All,

I know there are many threads on this, but I couldn't find an answer to my particular case... I have my script working and doing exacltly what I want it to, it's now a question of formatting... I'm using this to get a variable date and if that date falls on a Saturday or Sunday, I'm adding 2 days... The problem I cant figure out is where to format the date I get returned to a format I choose... (MM/dd/yy) or (yyyy-MM), etc... Here is the code... Any help would be appreciated...

Code: Select all

milday = 86400000;
d = new Date();
d = new Date(2019, 3, 23);
dmil = Date.parse(d.toString());
x = d.getDay();

if (x > 5)
	{
	dmil = dmil + (milday * 2);
	}

datenew = new Date(dmil)

		  
PDSource1 = datenew;

Re: Scripting the date

Posted: Mon Mar 25, 2019 9:05 am
by freddyp
You can get hold of the individual parts with the getDate(), getMonth(), getYear() functions and then you concatenate them in the way you need.