Skip to main content
Regexflux

Log Timestamp

beginner

Matches common timestamp formats found in log files.

logtimestampdatetimeparsing

Pattern

/\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:?\d{2})?/g

Try It

0 of 6 strings matched

Explanation

Matches ISO-style timestamps with T or space separator, optional fractional seconds, and optional timezone (Z or ±HH:MM).

Test Strings

Matching

  • 2024-01-15T09:30:00Z
  • 2024-01-15 09:30:00.123+05:30
  • 2024-01-15T09:30:00

Non-matching

  • Jan 15, 2024
  • 09:30:00
  • not-a-timestamp

Language Compatibility

LanguageSupport
JSFull support
PYTHONFull support
JAVAFull support
PHPFull support
GOFull support

Code Snippets

const regex = /\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:?\d{2})?/g;
const text = "your text here";
const matches = text.match(regex);
console.log(matches);

Related Patterns