Hello i need help with getting local time. If I use new Date() then I always get UTC time (2020-04-02T08:47:58.108Z"). But if I use the same command in in template (html) then I get time which I need (10:47:58 GMT +0200).
I need that local time in node red function and now i don't know how to do that.
And it is necessary to say that Ihave not full node red -because I work in mindsphere (from siemens) which using node red programming language.
In UI template, the time is client side (your browser). In function node, it's server time (where node red runs).
Which time do you want, and where do you want it?
Edit...
// In a function node you can get time for other timezones like this...
var aestTime = new Date().toLocaleString("en-US", {timeZone: "Australia/Brisbane"});
aestTime = new Date(aestTime);
var asiaTime = new Date().toLocaleString("en-US", {timeZone: "Asia/Shanghai"});
asiaTime = new Date(asiaTime);
var usaTime = new Date().toLocaleString("en-US", {timeZone: "America/New_York"});
usaTime = new Date(usaTime);
I need that european time (Berli, Prag, Budapest - CEST). And I need that time in node red function.
I need that time because in Mindsphere are data which I need get fetch by time. but data are saved with some timeshift (sometime just one hour and some time with 2 hours - summer/winter) . I need local time for fetching data and correctly show them on dashboard.
Are you sure, I will be amazed if the default method of storing the data in Mindshpere uses local time. What is the interface you use to fetch the data and can you point to the docs for this? Have you tried using the UTC time?
It is solved by Steve-Mcl - with time zone Europe/Prague
I wrote that wrong - Main problem is with showing data in dashboards with right time - in Mindspehere it is in UTC, but for my college I need to show data in time which is in our country.
when our machine is producing at 8:00 then Mindsphere saves data with time 6:00 (today) and last week it was with time 7:00 - because of winter/summer time. that is why I need to know local time - for the timeshift between time of saved data and machine/user time