function formatedDate (localid, inputdate) {
var locale = 'es_MX';
console.log(locale, inputdate)
// Set locale to moment
moment.locale(locale);
// Get locale data
const localeData = moment.localeData(locale);
const format = localeData.longDateFormat('L');
const m2 = moment(new Date(inputdate), format);
console.log(m2.format());
console.log(m2.format(format) + ' using format: ' + format);
return m2.format(format)
};
console.log(formatedDate('ex-MX', '2020-10-07T06:02:55Z'));
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment-with-locales.min.js"></script>
I need to convert dates according to the country/area , it depends completely base on location.
So I am trying to achieve this by using moment js
Here dates are stores in UST format in database
Example: If Input ''2020-10-07T09:30:00'
expected Output for 06/10/2020
Here date is formatting according to the locale but it not considering time, all regions it showing same date in different formats, based on time and locale it should format..
Note: I only need to display date (but while formatting time should consider)
In my angular application it not working as expected What I am doing wrong ,, Can any one help me .
Thanks in advance
from Moment localization not considering time while formating date?
No comments:
Post a Comment