2

As you know the format is like:

"YYYY-MM-DDTHH:NN:SS.ZZZ+XX:XX"  (i.e. "2009-03-24T16:24:32.057+01:00")

I have to do it in a ActionScript3 class but any source will be appreciated, thanks.

Tomalak
  • 332,285
  • 67
  • 532
  • 628
Giorgio Gelardi
  • 993
  • 4
  • 13
  • 29

5 Answers5

5
\d{4}-[0-1]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-6]\d.\d{3}\+\d\d:\d\d

Or something similar?

More checks of the valid range are probably better done after the reg.ex.

Douglas Leeder
  • 52,368
  • 9
  • 94
  • 137
  • 1
    You have an small typo: it should be "\d{4}-[0-1]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-6]\d.\d{3}\+\d\d:\d\d" (slash before +) – Alekc Mar 26 '09 at 11:38
3

Java regex, tested to read a date like "2001-12-15T07:30:40Z":

"^\\d{4}-[0-1][0-3]-[0-3]\\d{1}T[0-2]\\d{1}:[0-5]\\d{1}:[0-5]\\d{1}Z$"
xdazz
  • 158,678
  • 38
  • 247
  • 274
Al Ar
  • 31
  • 2
2

Have a look at this related question:

Actionscript 3 - Fastest way to parse yyyy-mm-dd hh:mm:ss to a Date object?

The accepted answer provides a way to parse an UTC time string to a Date object.

Community
  • 1
  • 1
Tomalak
  • 332,285
  • 67
  • 532
  • 628
1

Following Regex is perfect for any UTC date formats

"^(-?(?:[1-9][0-9]*)?[0-9]{4})-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[12][0-9])T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])(\\.[0-9]+)?(Z)?$"

Ref: https://www.regexpal.com/94925

Arzon Barua
  • 494
  • 7
  • 11
0

Regex should be something like this:

\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}\+\d{2}:\d{2}
Alekc
  • 4,682
  • 6
  • 32
  • 35