I have a date that I am bringing in from localStorage onto a Text input field but unfortunately the date string includes a time stamp when all I need is the date.
Is there some way of formatting the text input field so it will show Date only.
I am including some screen shots for detail.
Mike
This shows the Test Input field
This shows my attempt at formatting at the bottom which has not worked.
Hi @mdsmith1, if you only need the date we can use "moment.js" to format it. We could do it directly on the input, but it would be a better idea to do it before we add it to localStorage. Could you share how this date is getting to localStorage?
Let's say you have a JS query that does:
const date = new Date();
localStorage.setItem('mPaidDate', date);
Instead, format it before adding it:
const date = new Date();
const formattedDate = moment(date).format('MM-DD-YYYY'); // format date
localStorage.setItem('mPaidDate', formattedDate);