Writing to DateTime.UnixTimestamp causes error "UnixTimestamp is not a valid member of DateTime"

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 - The ScreenGui object this code runs under.
  • timeDate - A TextLabel 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:

  1. Open a Studio session.
  2. Enter the following on the command line.
dt = DateTime.now()
dt.UnixTimestamp = tick()
  1. Observe results.

I don’t think you’re supposed to write to this property. It’s like math.pi. I’d guess the error message is poorly formatted.

I ended up having to adjust my code to generate a new DateTime object on every loop iteration. What bugs me though is that the documentation doesn’t specify read only. I guess they didn’t consider someone trying it. I was attempting to do that for efficiency reasons on the client. This is a similar issue to where you cannot read the asset Ids from SurfaceAppearance or MaterialVariant. Took them forever to update the documentation for that.