Problem
When attempting to write to DateTime.UnixTimestamp
, an error is generated stating that “UnixTimestamp is not a valid member of DateTime”. I checked the documentation and there is nothing that says that I cannot write to this property directly. Here is the code excerpt in question:
task.spawn(function()
local timestamp
local datetime
local start
local text
local timeTable
while true do
timestamp = math.floor(tick() + timeOffset)
datetime = DateTime.fromUnixTimestamp(timestamp)
while clientGui.Enabled == true do
start = os.clock()
datetime.UnixTimestamp = timestamp
timeTable = datetime:ToLocalTime()
text = string.format("%04d/%02d/%02d<br/>%02d:%02d:%02d",
timeTable.Year, timeTable.Month, timeTable.Day,
timeTable.Hour, timeTable.Minute, timeTable.Second)
timeDate.Text = text
timestamp += 1
wait(1 - (os.clock() - start))
end
while clientGui.Enabled == false do
clientGui:GetPropertyChangedSignal("Enabled"):Wait()
end
end
end)
The following variables are defined externally from this code snipped:
-
clientGui
- TheScreenGui
object this code runs under. -
timeDate
- ATextLabel
object that is used for output. -
timeOffset
- A value to offset the current time (in seconds).
This occurs in both Studio and on a live server. This can also be reproduced directly on the Studio Command Line. I wish to point out that this may be a documentation issue as there is NOTHING saying that the property is read only (see image below).
Additional Information
Parameter | Value |
---|---|
Problem Area | Engine |
Problem Component | LUA API |
First Noticed | 30 March 2025 |
Priority | Normal |
Impact | Low |
Annoyance Level | Medium |
The beta features that I have enabled are as follows:
- Assistant Preview
- Texture Generator
As for plugins, I have a bunch that are installed, but very few are enabled. The ones that are enabled are listed below with links to their details page on the Roblox store website:
Expectations
Based on the documentation, I expect to be able to write to the UnixTimestamp property of DateTime without an error being thrown.
Visuals
Error Message
Documentation
URL: DateTime.UnixTimestamp
Reproduction
To reproduce the issue, perform the following steps:
- Open a Studio session.
- Enter the following on the command line.
dt = DateTime.now()
dt.UnixTimestamp = tick()
- Observe results.