How to get Local date and time?

If you need an Indicator or Signal developed or translated from other language, please post all Indicator development REQUESTS to this section here.

Moderator: admin

How to get Local date and time?

Postby conjure » Mon Aug 20, 2018 12:28 pm

Is it possible to get in my code,
Local date and time in format
19/08/18 16:30 ?
conjure
FXCodeBase: Initiate
 
Posts: 135
Joined: Sat Jul 22, 2017 7:27 am

Re: How to get Local date and time?

Postby Apprentice » Tue Aug 21, 2018 5:32 am

indicator.parameters:addInteger("ToTime", "Convert the date to", "", 3);
indicator.parameters:addIntegerAlternative("ToTime", "EST", "", 1);
indicator.parameters:addIntegerAlternative("ToTime", "UTC", "", 2);
indicator.parameters:addIntegerAlternative("ToTime", "Local", "", 3);
indicator.parameters:addIntegerAlternative("ToTime", "Server", "", 4);
indicator.parameters:addIntegerAlternative("ToTime", "Financial", "", 5);
indicator.parameters:addIntegerAlternative("ToTime", "Display", "", 6);



ToTime=instance.parameters.ToTime;

if ToTime == 1 then
ToTime=core.TZ_EST;
elseif ToTime == 2 then
ToTime=core.TZ_UTC;
elseif ToTime == 3 then
ToTime=core.TZ_LOCAL;
elseif ToTime == 4 then
ToTime=core.TZ_SERVER;
elseif ToTime == 5 then
ToTime=core.TZ_FINANCIAL;
elseif ToTime == 6 then
ToTime=core.TZ_TS;
end

local now = core.host:execute("getServerTime");
now = core.host:execute ("convertTime", core.TZ_EST, ToTime, now);
local DATA = core.dateToTable (now);


local Time = " Date : " .. DATA.month.." / ".. DATA.day .." Time: ".. DATA.hour .." / ".. DATA.min .." / ".. DATA.sec;
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36341
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: How to get Local date and time?

Postby conjure » Tue Aug 21, 2018 8:38 am

thank you :)
conjure
FXCodeBase: Initiate
 
Posts: 135
Joined: Sat Jul 22, 2017 7:27 am


Return to Indicator and Signal Requests

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 16 guests