9°C6:38 pmLondon, UK.

Format ISO date - JS

Format date from ISO string to different formats

Icon for Format ISO date - JS

Last updated: 29 Oct 2022

# javascript

import moment from 'moment';
export const formatDate = (value, includeYear = true) => {
/* Takes the date and returns it in this format 'Mar 21' */
return includeYear
? moment(value).format('MMM Do, YYYY')
: moment(value).format('MMM Do');
};
/* Takes the date and returns it in this format '2022-04-27' */
var date = new Date();
date.toISOString().substring(0, 10);

© 2026 Jide Abdul-Qudus. All rights reserved.

Built with Gatsby & Coffee.