ereg functions have been deprecated for quite some time, you should be using preg functions instead. See http://www.php.net/manual/en/reference.pcre.pattern.posix.php for more info.
You're use of substr makes no sense, you are getting a sub-string of the string starting at position 0 until the end of the string, this is the same as saying the whole string so there is no need to call substr.
Why are you calling mysql_real_escape_string on INCOMING data BEFORE you work with it? This function should be save ONLY for when inserting strings into a mysql dbms when using the mysql api. Speaking of which if you are using mysql you should definitely be using mysqli or PDO. See http://php.net/manual/en/mysqlinfo.api.choosing.php for more info.
And finally given you sample input data, what do you expect to get instead? The snippet you showed will not do anything to format the date for the day before. What the snippet you showed will do is remove all non-numeric characters from the string. In this case leaving you with '12162013120000' so you need to be more specific and make sure you are showing us the correct line that is giving you problems. IE tell us what you are giving it, what you expect to get back, what you get back instead and a few more relevant lines of code.