I have a given Date string, which is already formatted by moment.js by someone. I want to get that format.
I have checked existing questions and came across this one - check format of date with moment.js
The solution provided is not returning the format of the date. Rather it is validating against some given formats.
I want a function getMomentDateFormat like this -
var dateString = field.value; //"Nov 30, 2017"
var dateFormat = getMomentDateFormat(dateString ); //I want dateFormat = "MMM DD, YYYY"
You can use Parse Date Format plug-in:
Here an example (anyway it returns
MMM D, YYYY
instead ofMMM DD, YYYY
):PS. Do not use scripts directly from https://gr2m.github.io/, refer github repo.