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

185
Views
How to check if date string contains hours/min/seconds part?

I have JS string with date: 21-05-2022. It is also possible to receive date string as 21-05-2022T23:15:56Z - date string with date and time data. I would like to check if incoming string contains only date or date and time. Now I am using a function which splits string by 'T' symbol and checks if resulted array has second [1] member. Maybe there is more elegant way to perform this operation? I can use moment.js library in this context.

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

0

since your date is always string, i would do :
let result = dateString.includes('T'); if the string includes the T it means it is datetime

about 4 years ago · Juan Pablo Isaza Report

0

Alt variant: let isTimeHas = /:/.test(dateString)

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!