Question
· Feb 28, 2020

How to convert UTC to Eastern time

Does anyone know how to convert UTC to Eastern time in the DTL?  Input format "YYYYMMDDHHMMSS".

Can I use ConvertDateTime() function? If yes, what value do I use in these fields informat, outformat and outf?

Thank you.

Discussion (6)2
Log in or sign up to continue

HI Marc - how about during daylight savings time? Does this routine take care of that case even though we are specifying %K(-5)? May be use  $System.Util.IsDST() and do -4 if true.

Edit: That check if DST will not work if the input timestamp falls in DST but we are doing the conversion outside of that. There has to be an easier way to convert this (may be against the local OS timezone or something).

%K(-5) wouldn't take care of DST automatically. $ZDATETIMEH(myUTCTime, -3) will convert a $HOROLOG format (actually $ZTIMESTAMP format) value of UTC time into a $HOROLOG value in local time. So you can first use ConvertDateTime with %q(4) to convert to $ZTIMESTAMP format, then use $ZDATETIMEH with -3 to convert to local time, then use ConvertDateTime (or $ZDATETIME) to convert the $HOROLOG format back into a formatted date/time string.

https://docs.intersystems.com/healthconnectlatest/csp/docbook/Doc.View.c...

https://docs.intersystems.com/healthconnectlatest/csp/docbook/Doc.View.c...