How to set object's timestamp property through functions in foundry?

I am trying to set a timestamp property of object using foundry functions but it is giving me error.

I tried to pass this value in timestamp property but it gives me error

object.timeProperty = {type: 'Timestamp', dateTime: '2023-08-18T09:50:21.385Z'}

The error message that I get in preview tab is

r.getTime is not a function.
Error Parameters: {}
TypeError: r.getTime is not a function
    at Function.convertToPhonographTypeV2 (FunctionsFunctionsIsolateRuntimePackagePackage:84:23715)
    at t.TypeConvertingPropertyStore.convertToPhonographType (FunctionsFunctionsIsolateRuntimePackagePackage:362:6183)
    at t.TypeConvertingPropertyStore.set (FunctionsFunctionsIsolateRuntimePackagePackage:362:5943)
    at t.DefaultObjectStorageProvider.setPropertyValue (FunctionsFunctionsIsolateRuntimePackagePackage:100:35067)
    at t.MetricRecordingObjectStorageProvider.setPropertyValue (FunctionsFunctionsIsolateRuntimePackagePackage:322:9326)
    at t.OntologyAccessRecordingObjectStorageProvider.setPropertyValue (FunctionsFunctionsIsolateRuntimePackagePackage:325:701)
    at Proxy.setPropertyValue (FunctionsFunctionsIsolateRuntimePackagePackage:325:3257)
    at set commentTime [as commentTime] (OntologyObjectFactory:13:10868)
    at UserCode:22:33724
    at Array.forEach (<anonymous>)

Am I doing something wrong?, please guide.

Question originally asked by harsh2702 on Stack Overflow: How to set object's timestamp property through functions in foundry? - Stack Overflow

To edit a timestamp property, use the following code

import {Edits, OntologyEditFunction, Timestamp } from "@foundry/functions-api";
import { <your_object_type> } from "@foundry/ontology-api";

export class MyFunctions {
    @Edits(<your_object_type>)
    @OntologyEditFunction()
    public changeTimestamp(<your_object>: <your_object_type>): void {
        <your_object>.<object_ts_property> = Timestamp.fromISOString('2023-01-01T00:00:00.000Z')
    }
}

Run code snippet

Expand snippet

Answer originally provided by Ontologize on Stack Overflow: How to set object's timestamp property through functions in foundry? - Stack Overflow