Home > Net >  Format time zone to Vi Locale use Moment in React-Native
Format time zone to Vi Locale use Moment in React-Native

Time:07-08

i am having a date problem when using Moment in React-Native. Specifically, after I formatted the date to en locale, but now I want it to support the locale in my country is vi locale as well:

Moment('2022-09-02T02:00:00 00:00')
        .local()
        .format('dddd, DD MMM);

the out put:

Friday, 02 Sep

But I want the above result about our language in Vietnam as follows:

Thứ 7, 02 tháng 9

i tried as follows:

Moment('2022-09-02T02:00:00 00:00')
        .local()
        .format('dddd, DD MMM).locale('vi')

But it not slove this issue, so Does you guys help me this issue: Thanks,

CodePudding user response:

not same as you want but problem is you have to import localization also.

import moment from "moment";
import vi from "moment/locale/vi";
import fr from "moment/locale/fr";

const newVi = moment("2022-09-03T02:00:00 00:00").locale("vi", vi).format("dddd D, MMMM");
console.log(newVi);
const newFr = moment("2022-09-03T02:00:00 00:00").locale("vi", fr).format("dddd D, MMMM");  
console.log(newVi);
  • Related