SetTimeDisplay 1 day offset?

hello,
I discovered that the Unixtime I give as x-axis is converted in a date with one day offset
(graph->GetXaxis()->SetTimeDisplay(1):wink:
The unixtime is ok, I checked this.
How can I get the right date?
thanks
doris

Could you send the shortest possible running script showing the problem?
and tell us which version of ROOT?

Rene

hi,
the used root version is 5.14. but i also tried it with 5.16, (slc4, 32bit).
a short macro for the problem:
{
double now=time(NULL);

TCanvas outcan(“outcan”,“One Day”, 1200, 600);

//create a histogram with a time axis from now to now+24h
TH1F one_day(“one_day”, “One Day”, 1000, now, now+1* 86400);

TAxis *ax=one_day.GetXaxis();

ax->SetTimeFormat("[%d/%m %Hh]");
ax->SetTimeDisplay(1);

one_day.Draw();

}
thanks
greetings
doris

Do the following:

[code]{
time_t now=time(NULL);
gStyle->SetTimeOffset(now);

TCanvas outcan(“outcan”,“One Day”, 1200, 600);

//create a histogram with a time axis from now to now+24h
//TH1F one_day(“one_day”, “One Day”, 1000, now, now+1* 86400);
TH1F one_day(“one_day”, “One Day”, 1000, 0, 1* 86400);

TAxis *ax=one_day.GetXaxis();

ax->SetTimeFormat("[%d/%m %Hh]");
ax->SetTimeDisplay(1);

one_day.Draw();

}
[/code]

There is a default time offset in gStyle.

Rene

thank you.
with
gStyle->SetTimeOffset(0);
it works now. I didn"t know that there is complete day default offset in gstyle.
best regards
doris

sorry, but i recognized that there is still a time offset of +1 hour. unfortunately it didn"t work with SetTimeOffset(-3600) to correct this. This has no effect. why can I shift the time +1 hour with SetTimeOffset(3600) but not -1 hour?
thanks for help.
greetings
doris

If you want to start the origin exactly at the current hour+0 minutes, do

[code]{
ime_t now=time(NULL);
now = 3600*(int)(now/3600);
gStyle->SetTimeOffset(now);

TCanvas outcan(“outcan”,“One Day”, 1200, 600);

//create a histogram with a time axis from now to now+24h
TH1F one_day(“one_day”, “One Day”, 1000, 0, 1* 86400);

TAxis *ax=one_day.GetXaxis();

ax->SetTimeFormat("[%d/%m %Hh]");
ax->SetTimeDisplay(1);

one_day.Draw();

}[/code]

Rene