Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

266
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda