Extract 2 letters of a month

var getdate = require(‘moment’);
var requiredFormat = getdate().format((“MMM”));

When I use the above code I will get the month as “Mar”, but my requirement is I need it as just “MA”. How do I achieve this??

var getdate = require("moment");
var requiredFormat = getdate().format("MMM").substring(0,2).toUpperCase();
console.log(requiredFormat);
2 Likes

Awesome! Thanks @michaelderekjones

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.