Friendly Date Format - JavaScript

I have tried a few JavaScript variations to get the date to display in a way that is pleasing to the eye, but I am not having any success. In Microsoft Power Automate (Flow), I can accomplish this with a convert task that displays the date as desired for email notifications, etc., but in the Plumsail Edit form, the date looks too busy, and I don't want or need the timestamp.

How may I accomplish this format in Plumsail vs. the illustration below? Example: Friday, March 6, 2020

Hello @shedev,

You can convert the date to the local date format or to the usual date format.

Local date format:
new Date().toLocaleDateString();

Outcome: 02/03/2020

Date String:
new Date().toDateString();

Outcome: Mon Mar 02 2020

Or you can create a custom date format:

var d = new Date();
var days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];

var newDate = days[d.getDay()] + ', ' + months[d.getMonth()] + ' ' + d.getDate() + ", " + d.getFullYear();
console.log(newDate);

Outcome: Monday, March 2, 2020

Please find more information here.

1 Like

How were you able to convert this long date into a friendlier format in power automate? I tried the convert task in power automate and it didn't work. Can you post the formula you used in power automate?

I got it, the example below will let me extract the year. That way I can extract and create the date on the format I need.

var mydo = fd.field('DOB').value;

var de = new Date(mydo);

fd.field('Text6').value = de.getFullYear();

Hello @adasilva,

Tue Aug 15 1972 08:00:00 GMT-0400 (Eastern Daylight Time) — this is a standard string format of the date.

If you don't want to add/subtract time from date, or change the time zone no additional actions in Power Automate are required.