const d = new Date();
d.getTime();
how would i set a variable to that?Code:const d = new Date(); d.getTime();
![]()
JavaScript Date Methods
W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.www.w3schools.com
Control Variables -> Script and then type this in the box:how would i set a variable to that?
Date.now()
yeah, thats basically what i am doing. this is for a crop growth system so i need that subtraction methodControl Variables -> Script and then type this in the box:
JavaScript:Date.now()
Note that both this method, and Soulrender's, will give you the number of milliseconds that have passed since January 1, 1970 00:00:00 UTC. This is sufficient if you're trying to determine how much time has passed between one point and another. For example, I can use Date.now() right now, and store the value. Then I can use it again later, and subtract the previous value from it, and then I'll know exactly how much time has passed since I used it previously.
But if you're trying to actually display the date/time in a human-readable format, then it would be done differently--depending on exactly what you're trying to do.
yeah, thats basically what i am doing. this is for a crop growth system so i need that subtraction method
Date.now()
would definitely work for you then. Alternatively, you could use $gameSystem.playtime()
. Use the former if you want the crops to continue to grow even when the game is closed. Use the latter if you want the crops to only grow while the game is running.