Hi guys, thanks for every help then you give to me.
Now i need to solve this. I have a value sting date, I need to reformat it.
the orignal --> new format.
06/11/2020 --> 2020-11-06
How may I do it?
Hi guys, thanks for every help then you give to me.
Now i need to solve this. I have a value sting date, I need to reformat it.
the orignal --> new format.
06/11/2020 --> 2020-11-06
How may I do it?
You can do something like this:
function padZero(i) {
return i < 10 ? "0"+i : i;
}
const dateString = "06/11/2020";
const parts = dateString.split("/");
const date = new Date(Number(parts[2]), Number(parts[1]) - 1, Number(parts[0]));
const newDateString = date.getFullYear()+'-' + (padZero(date.getMonth()+1)) + '-'+padZero(date.getDate());
lets me try this!
Now is the question or the input date is US or rest of the world notation.
Eq is 6 the month or 11 the month
The "official" date is DD/MM/YYYY
Alternatively this might do it for you, assuming it is coming in in msg.payload then
msg.payload = msg.payload.split("/").reverse().join("-")
Ouuuwwww, very simple!!!
It works, thanks a lot.
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.