Session storage date picker

Anyone know how to get the session storage to work when the user input is a date picker?
Current code:

import { session } from ‘wix-storage’;

$w.onReady( function () {

$w(‘#input3’).value = session.getItem(“date”);

});

export function input3_change(event) {

var date = $w(‘#input3’).value
session.setItem(“date”, date);

}

Wix code SDK error: The value parameter that is passed to the value method cannot be set to the value Thu Jul 04 2019 00:00:00 GMT+0200 (sentraleuropeisk sommertid). It must be of type date.

Thanks

The session storage contains a string - which is not a date. However, you can use the string to create a date object, which you can then use as the value of the date picker. Something like this:

$w('#input3').value = new Date(session.getItem("date"));

Fantastic, thanks a lot!

When I copied and pasted the code you gave me, I got an error, but this piece of code worked:
$w(‘#input3’).value = new Date(session.getItem(“date”));

Is there a reason why you wrote ‘#input3’ twice?

Anyways, its working now, thank you

@mari Hmmm, I think it’s a forum issue. I wrote #input3 only once.

@yisrael-wix Ok I see, thanks for clarifying.

Yisrael, could you please help me with another issue? I posted a new thread here: https://www.wix.com/corvid/forum/community-discussion/session-storage-issue

If you have time, I would appreciate it a lot, been dealing with this issue for weeks…