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

241
Views
Trying to get moment to convert month to Number but i get incorrect value

Need help figuring out why moment is returning incorrect value. This is the problem i am facing. At anytime i can get either a french or english value. For example if cMon = "août 2022" when this code runs cNMon returns 2 instead of 8

i tried passing locale but the issue is it needs to be able to accept either french or english and display the correct value.

Line of typescript code

import moment from 'moment';


private static async getCurrent(actor: Actor): Promise<{ Mon: string, Year: number, MonStr: string, NMon: number}> {
        let cMon = await actor.requestTo(GetElementText.for(cmon));
        let Year = Number(currMonthText.split(" ")[1]);
        let MonStr = currMonthText.split(" ")[0];
        let cNMon: number  = Number(moment().month(currMonthStr.trim()).format("M"));

   

        return { cMon, Year, MonStr, NMon }
    }
about 4 years ago · Juan Pablo Isaza
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!