title: Go convert int64 (from UnixNano) to location time string
body: <p>I have an int64 like: </p>
  
  <blockquote>
    <p>1502712864232</p>
  </blockquote>
  
  <p>Which is the result of a REST GET to a service. I can convert it to a string easily enough. It is a Unixnano timestamp. </p>
  
  <p>What I really need is to convert it to a <strong>string</strong> which is related to a timezone like "Europe/London". Such as:-</p>
  
  <blockquote>
    <p>"14/08/2017, 13:14:24"</p>
  </blockquote>
  
  <p>Such as produced by this handy utility:
  <a href="http://www.freeformatter.com/epoch-timestamp-to-date-converter.html" rel="nofollow noreferrer">http://www.freeformatter.com/epoch-timestamp-to-date-converter.html</a></p>
  
  <p>Would very much appreciate any assistance.</p>
  
  <p>==> Update.</p>
  
  <p>Thanks to @evanmcdonnal for such a useful answer. Much appreciated.
  Turns out that the data I had was not UnixNano at all (sorry) it was milliseconds from Epoch. Source is a Jenkins timestamp....</p>
  
  <p>So... I wrote the following helper function to get what I need:</p>
  
  <pre><code>// Arg 1 is an int64 representing the millis since Epoch
  // Arg 2 is a timezome. Eg: "Europe/London"
  // Arg 3 is an int relating to the formatting of the returned string
  // Needs the time package. Obviously.
  
  func getFormattedTimeFromEpochMillis(z int64, zone string, style int) string {
      var x string
      secondsSinceEpoch := z / 1000
      unixTime := time.Unix(secondsSinceEpoch, 0)
      timeZoneLocation, err := time.LoadLocation(zone)
      if err != nil {
          fmt.Println("Error loading timezone:", err)
      }
  
      timeInZone := unixTime.In(timeZoneLocation)
  
      switch style {
          case 1:
              timeInZoneStyleOne := timeInZone.Format("Mon Jan 2 15:04:05")
              //Mon Aug 14 13:36:02
              return timeInZoneStyleOne
          case 2:
              timeInZoneStyleTwo := timeInZone.Format("02-01-2006 15:04:05")
              //14-08-2017 13:36:02
              return timeInZoneStyleTwo
          case 3:
              timeInZoneStyleThree := timeInZone.Format("2006-02-01 15:04:05")
              //2017-14-08 13:36:02
              return timeInZoneStyleThree
      }
      return x
  }
  </code></pre>