Understand UI time input data format

Hi,

I am using text input in dashboard / UI to set time.

What is the output format of the time set ?

When i set time to 01:00 i received the value 3600000 . How could i convert this number to "readable" and how could i split the number in Hours and minutes ?

Regards,

MD

Maybe this will help

Yes it helps. I should have seen that . Thanks,

How to convert and split this number in Hours and Minutes ?

MD

the node node-red-contrib-moment might be useful

alternatively there are lots of tutorials on line about javascript time, and use what you find in a function node

zenofmud ,

Thanks , the node-red-contrib-moment gives me the output > payload: "2019-04-29T09:27:30.839Z".
Now my problems is hot to extract Hour and Minutes and split them ? I thought Node-Red would be only graphic but it requires knowledge that i don´t have :slight_smile: .

ukmoose ,

I was googling in a wrong direction. Thanks for showing me a better path to search.

I will try !

MD

image may be something like this?

:+1: Uau , great tip. Thank you very much. I can even separate hour and minutes without writing code !!

image

Perfect !

Regards,

MD

Is possible to change the UI dashboard to output format time format as 23:00 instead of 11:00 PM ?

Regards,

MD

which output node are you using and what does it say in the info tab for the node?

You can have ultimate control if you use a function node. For example:

let d = new Date();
let day = d.getDay();  // Sun=0
let daysmins = d.getHours()*60+d.getMinutes();

All the date javascript functions are described here: https://www.w3schools.com/js/js_date_methods.asp

Hi,

I am very newbie on this subject so ; my understanding is that " d " is the variable " new Date ( ) but how should i know that adding a " d." to getHours() gives me a result ? Where can i learn this sintax ?

image

Regards

MD

https://duckduckgo.com/?q=javascript+date+methods&t=h_&ia=web

d is better described as a variable which references a Date object, which is set to the current date/time.
When you use d.something you are asking the Date object referenced by d to do something, in this case to call a member function Date.getHours() which is documented in many places which can be found as suggested by ukmoose. The w3schools site is a good place for information on javascript (and other web stuff).

Thanks for the explanation and links. Another doubt ;

Below an excerpt of a function to convert a number format.

var newMsg = { payload: decimal }; > This adds the value of Variable decimal to payload , right ? Where or what should i search for learning this syntax ?
return newMsg;

Thks

Regards

MD

There are numerous examples on the node-red website and lots of javascript tutorials on he web

https://duckduckgo.com/?q=learning+simple+javascript+objects+&t=h_&ia=web

It doesn't add the value of decimal to the msg.payload, it sets newMsg to an object that has a property payload which has the value from the variable decimal.
These are basic javascript features, so any javascript tutorial or documentation will teach you these concepts. Though the problem with javascript tutorials is that they tend to assume you are using the js in a website with html, whereas here it is being used as a standalone language. Whether anyone can recommend a particular one I don't know.

True, and often annoying. The w3schools site has a separate section on node.js that uses examples from running server-side programs and provides a programming tool. I haven't used it much, so I can't vouch for its quality.