Link to home
Start Free TrialLog in
Avatar of timberadmin
timberadminFlag for Canada

asked on

Excel datetime formatting UTC

Hi Experts,

In VBA, I am having trouble formatting a date/time into this UTC format like this: 2018-03-11T00:01:00Z

Please help...
Avatar of Bill Prew
Bill Prew

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You cannot just reformat it, it is a date offset
Set dateTime = CreateObject("WbemScripting.SWbemDateTime")    
dateTime.SetVarDate (now())
wscript.echo  "Local Time:  " & dateTime
wscript.echo  "UTC Time: " & dateTime.GetVarDate (false)

Open in new window
Avatar of Bill Prew
Bill Prew


That's not really true.  There are different formats for "UTC" time, see below link, specifically:

1994-11-05T08:15:30-05:00 corresponds to November 5, 1994, 8:15:30 am, US Eastern Standard Time.
1994-11-05T13:15:30Z corresponds to the same instant.
Date and Time Formats

This question didn't ask for info on calculating certain UTC values, rather just formatting a datetime value that had already been established...