String Pattern for DateTime.FromString

When using DateTime.FromString, I want to input a date formatted as “2016-09-22 00:37:27 GMT”. According to the Language Reference I should “Use format patterns from: Unicode Date Format Patterns.”
This would imply that I can specify a pattern such as “yyyy-MM-dd HH:mm:ss zzz” to input my dates the way I want, but I can’t find documentation on where and how I would specify this pattern.
Is this possible?

From what I understand the DateTime.FromString method automatically uses the best pattern. However to convert your string I needed to use this code:

Var time As String = "2016-09-22 00:37:27 GMT" Var dt As DateTime = DateTime.FromString(time, Nil, New TimeZone(time.NthField(" ", 3)))

You know this didn’t answer my question about why the doc says “Use format patterns” but then doesn’t say HOW to use format patterns.
But this did solve my issue, so I’m going to say it answered my question. :slight_smile:

you use one by specifying a specific locale - not the pattern itself

I’d ignore the link about formats since you dont have a direct way of using them given existing API’s

I agree with this statement in fact, but I should not have to ignore something that is written in the documentation. This is a red herring that cost me a couple of hours of running down the wrong path.
The problem was that neither the “en-US” locale or the default include the “zzz” for the timezone requiring a second step. The documentation implies the ability to use custom patterns which would allow this to be done in one step if it was true…which apparently it’s not.
Maybe in the future it will be.

Scott, report it in a feedback case. Documentation issues are generally fixed quickly.