Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

The 4th edition of the Campaign Community Lens newsletter is out now!
SOLVED

Workflow activity

Avatar

Level 2

Hi, 

 

One simple question.

How to print Yesterday date in JavaScript code activity log.

 

Regards 

Abhishek

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

One way to do it:

 

var d = new Date();
d.setDate(d.getDate()-1);
logInfo("Yesterdays date was: " + d.toLocaleString());

 


Output:
09/04/2020 13:24:33 js Yesterdays date was: Wed Apr 8 13:24:33 2020

Depending on what you need, you can refine the date format further using Javascript

3 Replies

Avatar

Correct answer by
Community Advisor

One way to do it:

 

var d = new Date();
d.setDate(d.getDate()-1);
logInfo("Yesterdays date was: " + d.toLocaleString());

 


Output:
09/04/2020 13:24:33 js Yesterdays date was: Wed Apr 8 13:24:33 2020

Depending on what you need, you can refine the date format further using Javascript

Avatar

Community Advisor
wow that code formatter is terrible...