fengari-lua / fengari-web

Provides everything you need to run Fengari in the browser.
MIT License
250 stars 19 forks source link

Help needed getting run time. #61

Closed Bat1963 closed 7 months ago

Bat1963 commented 7 months ago

Hello, I can get the current time in seconds as below:

timenow=window:Date()
hours=tonumber(timenow:sub(17,18)) mins=tonumber(timenow:sub(20,21)) secs=tonumber(timenow:sub(23,24))
starttime=hours*60*60+mins*60+secs

I can't seem to get the js getTime() or Date.now() things to work though. Basically, I was wondering if there is a way to do this through javascript. I actually don't need milliseconds, but I might in future!

daurnimator commented 7 months ago

Are you looking for js.new(js.global.Date)?

i.e. you want the equivalent of JS's new Date(), not Date() which is what you're doing