Working with UTC date Format

Salesforce CreatedDate and most other datetime fields comes in a GMT timezone, UTC format --> "yyyy-MM-dd'T'HH:mm:ss.SSSZ". This can be problematic when looking to perform calculations in the user timezone, especially if the date changes as a result of crossing a midnight barrier. 

Converting the field requires two steps: datevalue and date


Note the full datetime is required to convert into the epoch time format. Once in that format, DateValue reconverts it into a human readable and offsets the timezone.




1 comment

  • 0
    Jonathan Miller

    Thanks this was very helpful to me.  Only thing I had to change the format from "yyyy-mm-dd" to "yyyy-MM-dd" for it to work.

Please sign in to leave a comment.