Created
June 21, 2019 03:23
-
-
Save asmattic/4a46d02e51ddef0886ce50f20c759942 to your computer and use it in GitHub Desktop.
Format JavaScript date to common western string format (e.g. September 10, 2019)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Date formatter function | |
function formatDateString(dateExecutionVar) { | |
var date = new Date(execution.getVariable(dateExecutionVar)); | |
var monthList = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; | |
var month = monthList[date.getMonth()]; | |
var day = date.getDate().toString(); | |
var year = date.getFullYear().toString(); | |
return month + ' ' + day + ', ' + year; | |
} | |
execution.setVariable('Formatted_Date', formatDateString('Date')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment