calculate time zone or UTC

4535
12
12-19-2017 09:09 AM
JosephRogan2
New Contributor

Hello, I'm trying to calculate a custom string from a date and time using the now() function.  This gives my the local time, which is fine, kinda.  What I need to know is the timezone of this local time, or the zulu time.  I'm using the info found at:

https://community.esri.com/groups/survey123/blog/2016/04/17/dates-and-time-in-survey123-for-arcgis 

It would be great if there was a %timezone or something that returned the UTC offset but there isn't.  Is there any way to calculate this?  I'm wondering if it could be calculated out of a decimal date or something, but I'm limited to what I can use as a calculation in Survey123.

My goal is to write a military date-time group, EXAMPLE: 091630Z JUL 11 represents 1630 UTC on 9 July 2011.  There is more to my final formatting than that though, saving it as a date/time object won't help.

Thanks!

0 Kudos
12 Replies
by Anonymous User
Not applicable

Hi Joseph,

We do not currently have a property or parameter to return the UTC offset or timezone with a date/time question or in a string as part of a calculation. We have an open enhancement request to support UTC offset parameters and I have added your comments to the issue.

Regards,

Phil.

JamesTedrick
Esri Esteemed Contributor

Hi Jospeh,

With 2.7, Survey123 has just introduced UTC offset recording:

The function pulldata("@property", 'utcoffset') can now be used to capture and record the UTC time zone offset of the device.

by Anonymous User
Not applicable

James,

Can you share an example or has this function been added to a sample template?

Thanks

0 Kudos
JamesTedrick
Esri Esteemed Contributor

Hi Damien,

You will find the function at the bottom of the updated 'Date & Time' template.  It presents the offset in decimal hours (most timezones are an even number of hours off of UTC) to facilitate the addition.  True addition in Survey123 will be to add the offset value to the time recorded to create a 'fake' local time when downloading from AGOL.

RobertWeber
New Contributor III

James is there an example of this calculation somewhere?  I know it should be pretty straightforward to apply the utcoffset to now() but I am confused as to formatting of these values. 

0 Kudos
IsmaelChivite
Esri Notable Contributor

quick sample here. Do not forget to keep your UTC date as a string.

JoeFlannery
Occasional Contributor III

Ismael:

I am using the XLS Form Type "start" and "end" to capture the date and time the form was opened and then submitted.  The times recorded for start and end appear correctly in the survey's hosted feature service, but when printed to the a MS-Word report from the Survey123 webpage, the time is reported as 5 hours ahead (utcoffset).

Start Stop Times

I am using your information in an attempt to fix my offset time, but I don't understand your last comment "Do not forget to keep your UTC date as a string."

When I use the field types and calculations as shown, below, I get a 13 integer return.

calc

Start Stop Time2

What should my field types be in order to return a date and time in my time zone?  What am I doing wrong?

The Survey123 Community and I appreciate your time and attention to our questions.  Thank you!

Joe

0 Kudos
JamesTedrick
Esri Esteemed Contributor

Hi Joe,

I would suggest using the format-date() function to write out the time to a hidden/calculate question to store the date as a local string.

On the reporting of time 5 hours ahead, I can see this problem and have logged an issue to correct it.

0 Kudos
JoeFlannery
Occasional Contributor III

James:

Thank you for your attention.  I'll do that for now.

excel2

0 Kudos