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

259
Views
Casting string time to timestamp for calculation of date time difference?

I have data coming from an API which formats what should be a datetime object as a string. So the format is: "2021-04-22 19:32:00".

I have a start date and end date in this format.

Since it's a string, using JavaScript to pull out the hours isn't challenging, but I'm wondering, now that I have my two string variables of a theoretical begin and end time, how do I calculate how difference in these two parameters.

Meaning:

object 1 start time would be : "18:30:00". object 2 end time would be : "20:00:00".

And I want to know that difference is 90 minutes...

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

0

for this to work in safari you need to add a T to the middle to create a valid date

console.log(new Date("2021-04-22 19:32:00".replace(/ /,"T")))

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!