Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
[COLOR=darkgoldenrod]preg_replace[/color][teal]([/teal][green][i]'/(....)(..)(..)/'[/i][/green][teal],[/teal][green][i]'\\1-\\2-\\3'[/i][/green][teal],[/teal][green][i]'20100201'[/i][/green][teal]);[/teal]
list($start, $end) = explode('_', substr($filename, -21, 17));
Abit egocentric, aren't you ?jpadie said:3. strtotime can handle dates [red]justin fine[/red] in the YYYYMMDD format
[COLOR=darkgoldenrod]preg_match[/color][teal]([/teal][green][i]'/(\\d{4})(\\d{2})(\\d{2})[_.]?(\\d{4})(\\d{2})(\\d{2})/'[/i][/green][teal],[/teal][navy]$filename[/navy][teal],[/teal][navy]$m[/navy][teal]);[/teal]
[navy]$start[/navy][teal]=[/teal][COLOR=darkgoldenrod]implode[/color][teal]([/teal][green][i]'-'[/i][/green][teal],[/teal][COLOR=darkgoldenrod]array_slice[/color][teal]([/teal][navy]$m[/navy][teal],[/teal][purple]1[/purple][teal],[/teal][purple]3[/purple][teal]));[/teal]
[navy]$end[/navy][teal]=[/teal][COLOR=darkgoldenrod]implode[/color][teal]([/teal][green][i]'-'[/i][/green][teal],[/teal][COLOR=darkgoldenrod]array_slice[/color][teal]([/teal][navy]$m[/navy][teal],[/teal][purple]4[/purple][teal],[/teal][purple]3[/purple][teal]));[/teal]
[COLOR=darkgoldenrod]preg_match[/color][teal]([/teal][green][i]'/[highlight](.*)[/highlight](\\d{4})(\\d{2})(\\d{2})[_.]?(\\d{4})(\\d{2})(\\d{2})/'[/i][/green][teal],[/teal][navy]$filename[/navy][teal],[/teal][navy]$m[/navy][teal]);[/teal]
[highlight][navy]$name[/navy][teal]=[/teal][navy]$m[/navy][teal][[/teal][purple]1[/purple][teal]];[/teal][/highlight]
[navy]$start[/navy][teal]=[/teal][COLOR=darkgoldenrod]implode[/color][teal]([/teal][green][i]'-'[/i][/green][teal],[/teal][COLOR=darkgoldenrod]array_slice[/color][teal]([/teal][navy]$m[/navy][teal],[/teal][purple][highlight]2[/highlight][/purple][teal],[/teal][purple]3[/purple][teal]));[/teal]
[navy]$end[/navy][teal]=[/teal][COLOR=darkgoldenrod]implode[/color][teal]([/teal][green][i]'-'[/i][/green][teal],[/teal][COLOR=darkgoldenrod]array_slice[/color][teal]([/teal][navy]$m[/navy][teal],[/teal][purple][highlight]5[/highlight][/purple][teal],[/teal][purple]3[/purple][teal]));[/teal]
There you will have to use either -20 or -21, depending on the absence or presence of the separator character between the two dates. So the generic solution would be something like this :jpadie said:Code:$start = substr($filename, -2[red]0[/red], 8);
[navy]$start[/navy] [teal]=[/teal] [COLOR=darkgoldenrod]substr[/color][teal]([/teal][navy]$filename[/navy][teal],[/teal] [highlight][COLOR=darkgoldenrod]strpos[/color][teal]([/teal][green][i]'_.'[/i][/green][teal],[/teal][COLOR=darkgoldenrod]substr[/color][teal]([/teal][navy]$filename[/navy][teal],-[/teal][purple]13[/purple][teal],[/teal][purple]1[/purple][teal]))===[/teal]false[teal]?[/teal][/highlight][teal]-[/teal][purple]20[/purple][highlight][teal]:-[/teal][purple]21[/purple][/highlight][teal],[/teal] [purple]8[/purple][teal]);[/teal]