#Displaying Time
21 messages · Page 1 of 1 (latest)
because 3 * 8 = 24
(you shouldve tried logging out date on its own to debug first)
don't multiply it with 8, but add 8 to it
that is being added
multiplying by 8 on the time stuff is correct
if you had + 8 at the end it'd be +8ms
oh, true
then forget what I said
wait im so confused
@wooden garden what's plant.avgWaters and how are you using it?
Date.now() + 1000 * 60 * 60 * 8 is enough to display the time 8 hours from now
is plant.avgWaters how many time you water the plants a day?
and so 24 / plant.avgWaters === 8?
Date.now() + 1000 * 60 * 60 * (24 / plant.avgWaters)
plant.avgWaters is a number stored in mongo, it's amount of waters needed for plant to be harvestable
oh, ok
then your original code should work
Date.now() + plant.avgWaters * 1000 * 60 * 60 * 8
assuming you wait 8 hours between each time you water the plants
@wooden garden as ThatGuy said, 3 times 8 hours is 24 hours
so one more day, at the same time
if you are only display the time, you won't see the difference,
because 12/29/2023 at 12:46PM (now) and 12/30/2023 at 12:46PM (after watering the plants 3 times) will both display 12:46PM
you need to display the date too
add dateStyle: "short", when calling the toLocaleTimeString on your date
or use relative time ("In ... hours")