How do I get the unix timestamp of an hour and minute?

This topic is kinda flipped on it’s head from what it usually asks, but i’m asking to convert an hour and minute (like 8:48) into a unix timestamp. I dont think it matters what day it ends up recieving, as long as the hour and minute is accurate.
e.g. 7:46 → 1669103225000

Sorry misread the thread. Will come with a reply in a min.

Edit: Can you please specify for what purpose? :slight_smile:

Another edit: found this formula. It’s for Excell but the formula should still work.

In basic it’s (CurrentDate - DateDelta)*86400

The issue is that a Unix timestamp is the amount of seconds since Jan. 1, 1970. This means the date is built into it.
You can convert 7:46 to a timestamp on the day you collect that time from and disregard the date information if you want, but doing it that way seems a little strange.

As @TortenSkjold said, why do you want to do this?

If “7:46” is a string, you can use string.split() using : as the splitter. This will provide you with 2 arguments: the hours (7) and the minute (46). After that, you can easily convert 7 into 7*3600 (7 hours in seconds) and 46 into 46*60 (46 minutes into seconds). I haven’t tried it yet so if you can’t seem to make it work, I could give it a try.

This works exactly how i wanted it, thanks!

1 Like

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