Documentation
    Preparing search index...

    Class DateTimeProperty

    A property type that manages Dates, Timestamps, and ISO date strings. It automatically parses strings and standardizes UTC conversions depending on the global RETURN_AS setting.

    const createdAt = new DateTimeProperty({
    name: 'createdAt',
    timezone: 'UTC'
    });

    createdAt.set(new Date()); // Will store as UNIX timestamp if RETURN_AS is configured
    console.log(createdAt.val());

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    _allows: string[] = []
    _defaultValue: any
    _events: { [key: string]: Function } = {}
    _hasChanged: boolean
    _htmlType: PropertyHTMLType = 'off'
    _id: string
    _mandatory: boolean = false
    _name: string
    _parent: DataObjectClass<any> | undefined
    _protected: boolean = false
    _timezone: string
    _value: any = undefined
    AS_IS: string = 'asis'

    Return behavior to return the original Date object or string as is.

    EVENT_ONCHANGE: string = 'onChange'

    Event name triggered when the property value changes.

    EVENT_ONDELETE: string = 'onDelete'

    Event name triggered when the property is deleted.

    RETURN_AS: string = DateTimeProperty.AS_IS

    Global configuration determining the default format returned by val().

    TYPE: string = 'datetime'

    The string literal type identifier for this property.

    UNIX_TIMESTAMP: string = 'unix_timestamp'

    Return behavior to auto-convert dates into numeric UNIX timestamps.

    Accessors

    • get allows(): string[]

      Returns string[]

    • get hasChanged(): boolean

      Returns boolean

    • set hasChanged(val: boolean): void

      Parameters

      • val: boolean

      Returns void

    • get htmlType(): PropertyHTMLType

      Returns PropertyHTMLType

    • set htmlType(type: PropertyHTMLType): void

      Parameters

      Returns void

    • get mandatory(): boolean

      Returns boolean

    • get name(): string

      Returns string

    • get protected(): boolean

      Returns boolean

    • get timezone(): string

      Returns string

    Methods

    • Parameters

      • value: boolean | undefined

      Returns value is true | undefined

    • Creates a deep clone of the current property instance, preserving its prototype chain.

      Returns any

      A new independent instance of the property.

    • Assigns a new date value. If RETURN_AS is set to unix_timestamp, strings and JS Date objects are automatically parsed and converted to UNIX timestamps (milliseconds).

      Parameters

      • value: string | number | Date

        The date string, timestamp, or Date object to assign.

      • setChanged: boolean = true

        Whether to mark the property as modified.

      Returns DateTimeProperty

      The property instance for chaining.

    • Serializes the property for JSON stringification.

      Returns any

      The raw internal value of the property.

    • Retrieves the current value of the property, or its default value if currently undefined.

      Parameters

      • transform: any = undefined

        An optional transformation function applied to the value before returning it.

      Returns any

      The raw or transformed property value.