# Default Current Date & Time into a Field with Enate's Advanced Custom Cards

The following code can be added to a custom card to set the default value of a date/time field to the current date/time. In order to do this we need to use a third party object called 'moment' which lives in your browser, and will return the current datetime if we include it as a variable at the beginning of our code. This sample will assume the following:

* You have a custom card open
* It is set to 'Customised' in order to show the additional code tabs
* You have added a DateTime Field to your card - **here we will give it a name of 'CurrentDate' - you will have to adjust this name of the field referenced in your code in step 2 in order to match with your own specific field's name.**

When you set your card to 'Customised', all the previously auto-generated for the standard form layout remains for your use, so there are only two small lines of code to add, in two places. Follow the steps below:

**1. Declare 'moment' as a vairable**\
In the Typescript tab, add the following line of code **immediately after line 8**, to declare this 'moment' as a variable for subsequent use:

```
declare var moment; // Include moment in TypeScript
```

It should look like this in your code..

![](/files/-MejQv5_BXRDNr24ndsl)

**2. Add your custom code in the dedicated section to set your field value to the 'moment' value.**\
Further down in the Typescript code, add the following line **immediately after the  '//YOUR CUSTOM CODE BEGINS'** line:

```
this.Packet.DataFields['CurrentDate'] = moment().format("YYYY-MM-DD")+'T00:00:00';
```

It should look like this in your code..

![](/files/-MejS0rMDpsePIfYXXC8)

Note that you can adjust the date format to fit your needs.

**Save your card, and you're finished.**

Check out our Advanced Custom Cards section for more information about what they are and how to use them:

{% content-ref url="/pages/-MWitqjCWMF71qK0zuKG" %}
[Advanced Custom Card Code](/enate-help/integrations/enate-integrations/custom-card-content.md)
{% endcontent-ref %}


---

# Agent Instructions: 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:

```
GET https://docs.enate.net/enate-help/integrations/enate-integrations/sample-code-default-current-datetime-into-a-field.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
