# Set intial date for node input with type date

**URL:** https://discourse.nodered.org/t/set-intial-date-for-node-input-with-type-date/8629
**Category:** Developing Nodes
**Created:** [5 March 2019 13:22 UTC](https://discourse.nodered.org/t/set-intial-date-for-node-input-with-type-date/8629 "2019-03-05T13:22:27Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Callmoon](https://avatars.discourse-cdn.com/v4/letter/c/6de8d8/32.png) [@Callmoon](https://discourse.nodered.org/u/Callmoon)
#### Post date: [5 March 2019 13:22 UTC](https://discourse.nodered.org/t/set-intial-date-for-node-input-with-type-date/8629/1 "2019-03-05T13:22:27Z")

</div>

Hi folks,  
I try to create my own node which contains a **input** object with the **type** of **date** where this input object has as initial value the date of today (like if you use **new Date()**).

I've already tried something like the following **defaults** config, but the date input still has his initial value of **yyyy-mm-dd**.

```auto
...
  category: 'function',
        color: '#a6bbcf',
        defaults: {
            name: {value:""},
            date: {value: new Date()}
        },
        inputs:1,
        outputs:1,
...

```

---

<div class="post-metadata">

### Author: ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)
#### Post date: [5 March 2019 13:31 UTC](https://discourse.nodered.org/t/set-intial-date-for-node-input-with-type-date/8629/2 "2019-03-05T13:31:40Z")

</div>

Your `new Date()` call there will be evaluated whenever the editor is loaded - so the value will reflect that and not the point in time the node is added (which is what I assume you want?)

Also, you cannot use `Date` type for properties as it cannot be JSON encoded - you need to chose how to store the value as either a string or number.

You would then need to use the `oneditprepare` and `oneditsave` functions to populate the field from the node value and vice versa.
