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

265
Views
Extract substring of a string before specific character

I have this string 2022-04-01T09:00

I want to get rid of anything after letter T

I can explode it based on the letter T, and access the first element to get this 2022-04-01.

I wonder if there is a way to do that with JS without having to manually explode and so on...

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

A pretty simple easy to read solution would be to split the string by T and grab the first element like this:

"2022-04-01T09:00".split("T")[0]

Other alternatives include:

  • Using "2022-04-01T09:00".replace(/T.*$/, '') which will replace everything after (and including T) with an empty string.

  • Grabbing the first 10 characters using "2022-04-01T09:00".substring(0, 10)

about 4 years ago · Santiago Gelvez 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!