Orthanc date search for "today" and "yesterday" wrong by 1 day.

Hi, im really new to orthanc,
I was hoping someone could advise me on this possible error/bug?

Ive installed orthanc in 2 different PC,
And attempt to query retrieve from 3 different pacs.

both orthanc system seems to get dates for “today” and " yesterday" wrong by a day.

Eg, It is now 15th March, but upon searching for studies done “today”, it shows studies done on 14th March. Likewise, searching for studies done on “yesterday” shows studies on done 13th March instead.
When Orthanc1 queries studies done “today” from Orthanc2, its also shows studies done on 14th March (instead of 15th March)

Both system seems to have correct time in Windows.

Any idea if Orthanc has its own clock/date that I should correct?
Thanks in advance.

Ok im in +800 time zone. so im guessing Orthanc is assuming another time zone, instead of local time?

Did you install orthanc with postgres ? Timezone in you postgres may differ from you windows system

Yes, i believe I did. Should I remove it? or is there a way to set it to use local time?

Orthanc uses Postgres for handling better performance. Try google to edit your postgres configuration, here is one of them

For those of us using the osimis/orthanc docker-compose, is there a way to set the Postgres timezone?

Answering my own question: Of course, it’s just the standard postgres docker image. So, set TZ in environment.

Ugh. But that doesn’t work if you already have a database, of course.

Ok, I’m stumped.

I’ve set TZ and PGTZ in both my orthanc and postgres containers.
I’ve set timezone for the orthanc and postgres databases (SHOW TIMEZONE shows America/New_York).

If I say ‘date’ inside either container, it shows the right time.

Right now as i write this it’s 9:30PM. And yet, if I search for studies “today”, I get no results for a study done at 6PM. If I search for studies “yesterday”, I see that study - which was in fact done “yesterday” under UTC.

What am I missing?

Hmm, the issue seems to actually be on the web side - the dropdown for ‘today’, ‘yesterday’ etc is created in UTC. It still is even if TZ is set - it seems /etc/timezone doesn’t get set?

Sébastien, any ideas?

Found the bug. Sébastien, can you pretty please fix this?

The bug is in query-retrieve.js:

function JavascriptDateToDicom(date) { var s = date.toISOString(); return s.substring(0, 4) + s.substring(5, 7) + s.substring(8, 10); }

toISOString converts a date to UTC. That means that there is a period of time every day that “today” will be wrong. I suspect Sébastien never encountered this because he lives so close to UTC - so there’s only an hour or so - in the middle of the night - that this issue arises for him!

Some discussion of a solution here: https://stackoverflow.com/questions/17415579/how-to-iso-8601-format-a-date-with-timezone-offset-in-javascript

Here’s a replacement function:

function JavascriptDateToDicom(date)
// return a timezone-correct YYYYMMDD
const offset = date.getTimezoneOffset()601000;
var fakedate = new Date(date.getTime() - offset);
return fakedate.toISOString()

Or, simpler:

function JavascriptDateToDicom(d)


return ${d.getFullYear()}${(d.getMonth()+1).toString().padStart(2, '0')}${d.getDate().toString().padStart(2, '0')};


Dear Daniel,

Thanks for your investigation!

The fix has just been integrated into the mainline of Orthanc:


Thank you!