Title says it all. Here is my code incase your wondering:
local DateUploaded = DateTime.fromIsoDate(ProductInfo.Created)
if (tonumber(DateUploaded) < FirstItemDate) then -- FirstItemDate is a number
-- Continue code.
end
Error:
attempt to compare nil < number
Essentially, I need to convert the DateTime retrieved from DateTime.fromIsoDate(ProductInfo.Created) into a number so I can compare the two Unix timestamps.
DateTime is of type table, and it cannot be simply put through tonumber. For DateTime, you can use the “UnixTimestamp” property of the class. Example:
local DateUploaded = DateTime.fromIsoDate(ProductInfo.Created)
if DateUploaded.UnixTimestamp < FirstItemDate then
-- Continue code.
end