How to calculate local time?

2085
6
04-05-2017 01:44 AM
vanessagiles
New Contributor III

I am trying to calculate the local time (10 hours ahead of UTC) into a new field using this statement:

${dTime} + (1000 * 60 * 60 * 10)

But I get an answer that looks like its in EPOCH time (see attached.

How can I get the local time into a field in ArcGIS online? 

(If I leave it in UTC time then the dates are split by the midnight mark and I can't filter my map layers properly).

Tags (3)
0 Kudos
6 Replies
JayantaPoddar
MVP Esteemed Contributor

Check if the following link is useful.

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

Calculations: Calculations are easy too, as long as you understand that dates in the Survey123 app are encoded as EPOCH time. When users pick a date or a date-time in the survey, all values will be presented in a human friendly way, but internally the application is actually handling them as numbers that represent the total milliseconds elapsed since 1970. A positive number represents a date after 1970 and a negative number a date in the past.  As you can imagine those are pretty big numbers, but the math is simple. For example:

 

GoalExpression
Calculate a time 15 minutes into the futurenow() + 15*60*1000
Calculate age from a birthdayint((today() - ${birth_date}) div (1000 * 24 * 60 * 60 * 365.25))
Time spent for lunchint(${TimeLunchEnds} - ${TimeLunchStarts}) div (1000*60)
Two weeks into the futurenow() + 14*24*60*60*1000


Think Location
0 Kudos
vanessagiles
New Contributor III

Thanks, I have read this blog post but I don't understand - how can I get the local time to display in a legible date-time format in my attribute table?

0 Kudos
JamesTedrick
Esri Esteemed Contributor

Hi Vanessa,

What product are you using to display the time information? ArcGIS Online automatically compensates for the time zone difference between your computer's local time zone and UTC.  ArcGIS Desktop (ArcMap and ArcGIS Pro) both have tools to compensate from UTC in the time display as well as calculate the difference in time zones on a table.

0 Kudos
vanessagiles
New Contributor III

Thanks James - I was viewing it through a browser using a shared URL (demo with users).  It was definitely not showing the local time.  ArcGIS online was displaying the local time this morning.  I will do some further testing to see if I can replicate the problem.

0 Kudos
JamesTedrick
Esri Esteemed Contributor

No worries- ArcGIS Online stores all time information as UTC (see Troubleshoot—ArcGIS Online Help | ArcGIS ).  Assuming the computer is aware of what time zone is, the browser should be automatically adjusting it in the display.

0 Kudos
ChrisWest
New Contributor

Do you have a fix for the time being off in Survey123? My team goes out and log items and the time stamp for them is a date choice in the survey. But the time is off by 8 hours in the EST zone. Can the survey pull the time from their phone or device?

0 Kudos