My game involves a series of forum posts. I would like to make it so that those in a certain topic were posted days ago, and in another topic were posted months ago.
So, the player would look at the date posted and find it to be, for instance, two days before the current, out of game date.
How would I do this? Is it even possible?
You’d do something like this:
/% create date object with current time and date %/
<<set $date = new Date()>>
Current: <<print $date>>
/% set the month to 2 less than current month %/
<<set $date.setMonth($date.getMonth() - 2)>>
Two months ago: <<print $date>>
Here is a reference on all of the stuff you can do with the date object: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date
Edit: This post is assuming that you’re using SugarCube. I just realized that you never specified. I’m not very knowledgeable of Harlowe and I can’t seem to figure out how to get it to work with the new
operator. So hopefully you are using SugarCube.
If it helps, I have a lot of time and date sample code for Twine/SugarCube you could take a look at. (Click “Jump to Start” in the UI bar to see other sample code there.)