Scripting the date

Post Reply
apietrocini
Member
Posts: 32
Joined: Fri Mar 24, 2017 7:06 pm
Location: Cleveland, OH

Scripting the date

Post 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;
freddyp
Advanced member
Posts: 1008
Joined: Thu Feb 09, 2012 3:53 pm

Re: Scripting the date

Post 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.
Post Reply