# Capturing today's date for CMS field

**URL:** <https://forum.wixstudio.com/t/capturing-todays-date-for-cms-field/58468>\
**Category:** Ask the community\
**Tags:** code, cms, wix, question\
**Created:** [April 22, 2024, 7:01pm UTC](https://forum.wixstudio.com/t/capturing-todays-date-for-cms-field/58468 "2024-04-22T19:01:24Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![thomasj](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/thomasj/32/30791_2.png) [@thomasj](https://forum.wixstudio.com/u/thomasj)\
**Post date:** [April 22, 2024, 10:07pm UTC](https://forum.wixstudio.com/t/capturing-todays-date-for-cms-field/58468/2 "2024-04-22T22:07:19Z")

</div>

Inserting a date into a CMS collection field depends on the field data type and options.

It’s important to check whether “Include time field” is selected as it will affect how you need to insert data into your CMS collection.

 ![Date CMS Field Options](https://us1.discourse-cdn.com/wix/original/3X/1/b/1bf4a7f5c6c562fd20de335d438751f2dc236885.png)

If you have a “Date” Field **without** “Include time field” selected, the string that is written to the collection must be in ISO 8601 format without the time.

**Example**

```javascript
let dateObject = new Date();
let toInsert = {
    "_id": "00001",
    "title": "Item 01",
    "date": dateObject.toISOString().substring(0, 10)
};

```

If you have a “Date” Field **with** “Include time field” selected, the string must be written to the collection using a JavaScript Date Object.

**Example**

```javascript
let dateObject = new Date();
let toInsert = {
    "_id": "00001",
    "title": "Item 01",
    "date": dateObject
};

```

For more information check out the documentation below:

> **[Working with the Data API](https://dev.wix.com/docs/develop-websites/articles/databases/wix-data/data-api/working-with-the-data-api#date-fields)**
>
> Velo: Working with the Data API Visit the Velo by Wix website to onboard and continue learning. Introduction The Wix Data API lets you work with your database collections using code and gives you more capabilities than what is available in the editor...

---

_[View the full topic](https://forum.wixstudio.com/t/capturing-todays-date-for-cms-field/58468)._
