Regular Expressions 101

Community Patterns

Transform a date string into a timestamp

0

Regular Expression
PCRE2 (PHP >=7.3)

/
^[\w,]{3,4} (?: (?<jan>Jan )| (?<feb>Feb )| (?<mar>Mar )|(?<apr>Apr )|(?<may>May ) |(?<jun>Jun ) |(?<jul>Jul ) |(?<aug>Aug ) |(?<sep>Sep ) |(?<oct>Oct ) |(?<nov>Nov ) |(?<dec>Dec ))(?<day>\d+) (?<year>\d+) (?<time>\d{1,2}:\d\d:\d\d).*
/
gm

Description

Transform a date string like: Mon Nov 10 1957 12:34:56 UTC +08:00 into: 11/10/195 12:34:56

Submitted by Steve Aughnbaugh - a year ago (Last modified a year ago)