Skip to main content

How do I convert unix timestamps so I can load my date controls on my form?

Comments

2 comments

  • Hi Justin

     

    the date is in seconds since 1/1-1970.

     

    The trick is to create a new datetime objekt and ad the number of seconds, and then convert to localtime.

     

    Unixdate=1521096141

     

    startDate = new DateTime(1970,1,1,0,0,0,DateTimeKind.Utc)

     

    newdate = startDate.AddMilliseconds(UnixDate).ToLocalTime()

     

    form.Find(Of DatePickerFormItem)("DatePicker1").InitialDate=newdate

     

     
    0
  • Justin Kraemer
    Because I was pulling attributes from the selected feature, I found the trick was to add a query to get just the two date fields by the ObjectID of the selected feature and use that featureset in the next steps. I can't explain why this second featureset was necessary when I already had the initial one, but the next step was to assign the date attribute to an object variable, then cast this object variable to a DateTime variable, and finally assign that variable to 

     

    form.Find(Of DatePickerFormItem)("DatePicker2").InitialDate
    0

Please sign in to leave a comment.