#Displaying Time

21 messages · Page 1 of 1 (latest)

remote hinge
#

if plant.avgWaters is 3 then you're just getting 24 hours ahead instead of 8

#

because 3 * 8 = 24

#

(you shouldve tried logging out date on its own to debug first)

ruby hound
#

don't multiply it with 8, but add 8 to it

remote hinge
#

that is being added

#

multiplying by 8 on the time stuff is correct

#

if you had + 8 at the end it'd be +8ms

ruby hound
#

then forget what I said

wooden garden
#

wait im so confused

maiden lake
#

@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)

wooden garden
maiden lake
#

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")