Formatting Dates in Magento Javascript
dateFormat
string
defaults: {
dateFormat: 'MMM d, YYYY h:mm:ss A'
},
Chances are its a Moment.js
date format string.
You can pull in the main moment
function via a RequireJS shim
define(['moment'], function(moment){
});
And the mageUtils
RequireJS library (an alias for mage/utils/main
) appears to export a normalizeDate
function that will convert Magento’s old custom date format into a Moment.js based format.
define(['mageUtils'], function(mageUtils){
momentFormat = mageUtils.normalizeDate(oldMageFormat);
});