# utcDateTime

Industry: Core

```ts
const utcDateTime: RegExp = /^(?:\d{4}|\+\d{6}|-(?!0{6})\d{6})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])T(0[0-9]|1[0-9]|2[0-3]):[0-5][0-9](?::[0-5][0-9](?:[.,]\d{1,9})?)?Z$/;
```

RegExp matching ISO 8601 UTC datetime: `<date>T<time>Z` with optional fractional seconds, in ISO 8601 extended format. The designator is an upper-case `Z`: a lower-case `z`, which RFC 3339 §5.6 and Temporal also read, does not match (`rfc3339DateTime` is the RFC 3339 pattern that accepts it).

## Examples

```ts
import { utcDateTime } from "@northguild/gmt";
```

```ts
utcDateTime.test("2024-03-15T14:30:00Z") // true
utcDateTime.test("2024-03-15T14:30z") // false (lower-case z)
utcDateTime.test("2024-03-15T14:30:00.123Z") // true (fractional seconds)
utcDateTime.exec("2024-03-15T14:30:45.5Z")?.slice(1) // ["03", "15", "14"] (month, day, hour)
utcDateTime.test("-000000-01-01T00:00Z") // false (negative zero year)
utcDateTime.test("2024-03-15T14:30:00+00:00") // false (numeric offset)
utcDateTime.test("2024-03-15T14:30:00") // false (no timezone)
```

## Source

[regex/utc-date-time.ts](https://github.com/northguild/gmt/blob/main/packages/gmt/src/regex/utc-date-time.ts)
