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

93
Views
How to create pattern for numbers

there. I have a number 20220112 which i need to convert this number to string which will look like this 2022-01-12 Maybe anone knows is there are some patterns in JS which i could use for easy convertation?
Something like const date = patetn(****-**-**) ?

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

0

Write a function where you first cast the passed value to a string. then you can format the string to your pattern.

function formatNumber(num) {  
    return String(num).replace(/(\d{4})(\d{2})(\d{2})/, '$1-$2-$3');
}

console.log('formatted: ', formatNumber("20220401") )

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!