How to change json date to mm/dd/yy using moment.js?

Member

by jasen , in category: Javascript , a year ago

How to change json date to mm/dd/yy using moment.js?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by denis , a year ago

@jasen 

You can use moment.js to format the JSON date to mm/dd/yyyy format by using the following code:

1
2
3
4
5
6
7
// assuming your JSON date is stored in a variable called jsonDate
var jsonDate = "2021-08-10T10:30:00";

// parse the JSON date using moment.js
var formattedDate = moment(jsonDate).format("MM/DD/YYYY");

console.log(formattedDate); // Output: 08/10/2021


This code snippet will convert the JSON date "2021-08-10T10:30:00" to the formatted date "08/10/2021".

Related Threads:

How to change date format to 'dd-mon-yy' in oracle?
How to add days using moment.js with format of mm/dd/yyyy?
How set the datepicker in moment.js to yyyy-mm-dd?
How to combine three variables into a date (mm/dd/yyyy) in teradata?
How to insert date in yyyy-mm -dd hh24:mi:ss in oracle?
How to change the date using moment.js?