C# uses string like that 'dd MMMM yyyy HH:mm'
to define format the date and time should be displayed in.
Equivalent of that in momentjs is 'DD MMMM YYYY HH:mm'
.
Is there some function that can covert one format definition into the other regardless of what (legal) combination of format specifiers source format contains?
Basically what I want is:
function toMomentJsFormatDefinition(cSharpFormatDefinition) {
// should convert all format strings described here https://msdn.microsoft.com/en-us/library/8kb3ddd4%28v=vs.110%29.aspx
}
console.log(toMomentJsFormatDefinition('dd MMMM yyyy HH:mm'));
// outputs DD MMMM YYYY HH:mm
Ideally toMomentJsFormatDefinition
should be defined in some already written and fairly well tested library I'll just use in my project.
I had the same task and created the following utility function to convert a DateTime Format String from Dotnet to MomentJS format.
Usage:
Code: