Convert a string into a 24 hours date and substract hours or minutes

Hello,

My problem is quite precise but keeps bugging me despite extensive researches, maybe you can help.

Let’s say I have
const timeString = “18:30”

How can I convert into a date/time and say substract 35 minutes to it ?

Thank you in advance !

Vnvl

Hello,

I think I see what you mean, so I tried this and effectively it is an option :

const date = new Date()
const now = date.getTime()
const before = now - 30000000000

const result = new Date(before).toDateString()

So it works for me. So you cannot only consider “18:30” and then take 1 hour, you have to put a Date in front and then it will work.

Thank you,

Vnvl

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.