Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

279
Views
Intl not working for Android in React Native

I am getting value like 202001.

I want to covert it like January_2020.

Is there a way to convert it like this?:

202001->January_2020

i tried below one.

const dateToStr = (input) => {
    if (input.length !== 6) {
      return "wrong date syntax, use YYYYMM";
    }
    const parts = input.match(/([0-9]{4})([0-9]{2})/);
    if (!parts) {
      return "wrong date syntax, use YYYYMM";
    }
    // NOTE: check syntax of parts
    const formatter = new Intl.DateTimeFormat("en-EN", { month: "long" })
      .format;
    const formatted = formatter(
      new Date(Date.UTC(parseInt(parts[1]), parseInt(parts[2]) - 1))
    );
    return `${formatted}_${parts[1]}`;
  };

it is working fine for ios but not working in android.

it showing error like:--

can't find variable:Intl

How can i get this updated value in Javascript without using any library in android and ios both?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

No need to use Intl.DateTimeFormat. You may simply use Date class.

const dateToStr = (input) => {
    if (input.length !== 6) {
      return "wrong date syntax, use YYYYMM";
    }
    const parts = input.match(/([0-9]{4})([0-9]{2})/);
    if (!parts) {
      return "wrong date syntax, use YYYYMM";
    }
    const monthNumber = Number(parts[2]);
    if (monthNumber < 1 || monthNumber > 12) {
        return "Wrong month number.";
    }
    const d = new Date();
    d.setMonth(monthNumber-1);
    const monthName = d.toLocaleString("en-EN", {month: "long"});
    return `${monthName}_${parts[1]}`;
  };
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!