> For the complete documentation index, see [llms.txt](https://quick.ortusbooks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://quick.ortusbooks.com/13.0.0/guide/getting-started/automatic-timestamps.md).

# Automatic Timestamps

Quick can maintain conventional creation and modification timestamps for you. Automatic timestamps are enabled by default in Quick 13.

When an entity declares `createdDate` and `modifiedDate` attributes, Quick will:

* set both attributes before inserting a new entity;
* set `modifiedDate` before updating an existing entity;
* add `modifiedDate` to `updateAll` and the update side of `upsert`; and
* add both timestamps to literal rows inserted through `upsert`.

Explicitly assigned timestamp values are preserved.

```javascript
component extends="quick.models.BaseEntity" accessors="true" {

    property name="id";
    property name="createdDate" column="created_date";
    property name="modifiedDate" column="modified_date";

}
```

Timestamps are assigned before the `preSave`, `preInsert`, and `preUpdate` lifecycle events, so event listeners see the values that will be persisted.

## Custom Attribute Names

Use component metadata when your entity uses different attribute names:

```javascript
component
    extends="quick.models.BaseEntity"
    accessors="true"
    createdDateAttribute="createdAt"
    modifiedDateAttribute="updatedAt"
{

    property name="id";
    property name="createdAt" column="created_at";
    property name="updatedAt" column="updated_at";

}
```

Quick only writes timestamp attributes that are declared on the entity.

## Disabling Automatic Timestamps

Disable automatic timestamps for the entire application in your module settings:

```javascript
moduleSettings = {
    "quick" : {
        "automaticTimestamps" : false
    }
};
```

You can override the setting for one entity:

```javascript
component extends="quick.models.BaseEntity" accessors="true" automaticTimestamps="false" {
    // properties...
}
```

Or disable timestamps for one builder chain:

```javascript
getInstance( "User" )
    .whereId( 1 )
    .withoutAutomaticTimestamps()
    .updateAll( { "firstName" : "Jane" } );
```

## touch

`touch()` updates the attributes returned by `timestampFields()` using a separate query.

```javascript
var user = getInstance( "User" ).findOrFail( 1 );
user.touch();
```

By default, `timestampFields()` returns the declared `createdDate` and `modifiedDate` attributes. Override it to choose different fields:

```javascript
public array function timestampFields() {
    return [ "modifiedDate" ];
}
```

`touch()` does not change the entity's in-memory attributes or dirty state. Call `refresh()` when you also need the updated values on the current instance.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://quick.ortusbooks.com/13.0.0/guide/getting-started/automatic-timestamps.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
