Function to check if a date is correct
The reason PHP dislikes the use of Regex is because some people don't know how to use it.
You, for example, don't.
Regex is for matching input, not for validation.
And so you'd use it to change say your date format to ISO 8601:

&gt; $date = '19700101000000';
&gt; preg_replace('/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/', '$1-$2-$3T$4:$5:$6Z', $date);
=&gt; "1970-01-01T00:00:00Z"


The regex is simple as we know the data should be there. Not that it's correct.

Your code is also long-winded, rather than manually checking if the code is alright make PHP do it for you with strptime.
You know the format the date is in, %Y%m%d%H%M%S, and so you can use it:

&gt; strptime($date, '%Y%m%d%H%M%S');
=&gt; {"tm_sec":0,"tm_min":0,"tm_hour":0,"tm_mday":1,"tm_mon":0,"tm_year":70,"tm_wday":4,"tm_yday":0,"unparsed":""}


And so you could change the function to just use:

/**
  * Function that checks the format, date, and time of a given timestamp.
  * @author : somar
  * @param string $date timestamp ex: 20161230154523
  * @return boolean resultat de check
  */
public function validateDate($date)
{
    return (bool)strptime($date, '%Y%m%d%H%M%S');
}




To note, strptime seems to have a bug with %S:

&gt; strptime('19700101000070', '%Y%m%d%H%M%S');
=&gt; {"tm_sec":7,"tm_min":0,"tm_hour":0,"tm_mday":1,"tm_mon":0,"tm_year":70,"tm_wday":4,"tm_yday":0,"unparsed":"0"}


To fix this you could change the function to take ISO 8601 dates, and have a function that converts to this format.

/**
  * Function that checks the format, date, and time of a given ISO 8601 timestamp.
  * @author : somar
  * @param string $date timestamp ex: 2016-12-30T15:45:23Z
  * @return boolean resultat de check
  */
public function validateDate($date)
{
    return (bool)strptime($date, '%Y-%m-%dT%H:%M:%SZ');
}

public function compactDateToISO($date)
{
    return preg_replace('/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/', '$1-$2-$3T$4:$5:$6Z', $date);
}