Friday, September 1, 2017

UTC formatted string time to local time in Word

Leave a Comment

I have a Document Property that stores a DateTime in the UTC format.

For example:

2017-08-23T11:42:55.1094139Z 

Now I would like to display this DateTime in my Word Document, there for I use the following field:

{ DOCPROPERTY LAST_UPDATED } 

(FYI: LAST_UPDATED isnt the DateTime the file was last modified, but the last time the user clicked a sync button of my addin)

This will display the string as is, so in the UTC format.

I hoped that the following, would turn the UTC into the local DateTime.

{ DOCPROPERTY LAST_UPDATED \@ "dd.MM.yyyy HH:mm:ss" } 

but sadly, it ignores the CurrentCulture/LocalTimeZone completly and just displays it as

23.08.2017 11:42:55 

Instead of the desired

23.08.2017 13:42:55 

How can I achieve my goal? Store a DateTime in my Word Document that is independet of Region/TimeZones and let it display the local time?

0 Answers

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment