Hello, Developers and all alike!
I created this TimeStamp Module that was originally just going to be a part of a public resource I’m working on. Here’s how you use it!
local timeStamp = require(TimeStamp)
local RightNow = DateTime.now()
local TextLabel = Instance.new("TextLabel")
local myCoolStamp = timeStamp.Cache(TextLabel, RightNow, "$timeDifference ago")
$timeDifference
returns “0 Seconds”
The textlabel’s Text property will update every second for how many seconds ago the RightNow variable was, until the RightNow variable turns into minutes, which then it will minimalize the resources and only appropriately update every minute.
$date
returns “November 10th, 2024” if it was over a day ago, and all the other formatting keywords return parts of $date!
If it’s the same day as the DateTime given (on the client’s time zone), it will return “Today at 12:00 AM”
If it was yesterday (on the client’s time zone), it will return “Yesterday at 12:00 AM”
$date
and all its sub-keywords don’t update at all, leaving the text property as is.
the TimeStamp module is object oriented, so make sure to keep it as a variable so that you can call myCoolStamp:Destroy()
whenever you need to!
Or don’t keep it as a variable, that’s fine too! You can run timeStamp:FindTimeStamper(TextLabel)
to grab a Cache’d time stamp attached to the given instance!
Use myCoolStamp:Toggle(act: boolean?)
to activate/deactivate the updates!
Use myCoolStamp:EditFormat(newString: string?, priorityChange: boolean?)
to change the given format of the timeStamp object!
Use myCoolStamp:Update()
to force an update on the timeStamp object.
To those blind to links, here’s the raw link!