Although regex is actually not a good solution for parsing dates in the YYYYMMDD format, skip why your template does not work.
Your pattern \d{4}\\d{2}\\d{2}\ says: "matches 4 digits ( \d{4} ), followed by a backslash ( \\ ) followed by a letter d twice ( d{2} ), and then another backslash (), and then finally two more d ( d{2} ).
As you may have already figured out, you do not need double slashes!
\d{4}\d{2}\d{2}
Will correspond to 4 digits, and then 2 digits, and then 2 more digits.
In addition, you do not specify capture groups , so your subpatterns will never be filled. You probably meant:
(\d{4})(\d{2})(\d{2})
See this in action at http://www.ideone.com/iAy7K . Note that in your case there is no reason to specify the flag PREG_OFFSET_CAPTURE (which returns the position of each match) or 0 for offset.
source share