What format are you receiving your UTC dates in?

If they are proper ISO 8601 strings, then you can get the expected Date 
with `fromIsoString` from here: 
http://package.elm-lang.org/packages/justinmimbs/elm-date-extra/2.0.1/Date-Extra#fromIsoString.
 
To be recognized as UTC time the string must include a time zone offset of 
"+00", "+0000", "+00:00", or "Z", e.g. "2016-11-16T14:00Z". If no time zone 
offset is present, the string is assumed to represent local time.

If you have date parts that represent a UTC time, then you can construct 
the expected Date with `fromSpec`, 
http://package.elm-lang.org/packages/justinmimbs/elm-date-extra/2.0.1/Date-Extra#fromSpec.


import Date.Extra exposing (utc, atTime, calendarDate)

Date.Extra.fromSpec
  utc
  (atTime 14 0 0 0)
  (calendarDate 2016 Nov 16)



Once you have a Date representing the desired UTC time, then its 
extractions will represent the machine's local time. Formatting functions 
usually default to representing the date in local time too. Does this help?



On Tuesday, November 15, 2016 at 10:27:57 PM UTC-5, Liam Curry wrote:
>
> I have some UTC dates that I need to show in the users local time. All I 
> really need is the users local timezone offset, which I can then use to 
> calculate the date in their local timezone.
>
> I've looked over several Date/Time packages and none of them seem to do 
> this. Am I missing something, or is there no easy way to do this in Elm 
> without using Native code?
>

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to