Excel time
function exceltimtetophp ($days, $time =false)
{
if (Is_numeric ($days))
{
Caesar's Day count, to use the date we applied from 1970 onwards the function Gregoriantojd (), converted to Caesar day count
$JD = GREGORIANTOJD (1, 1, 1970);
$gregorian = Jdtogregorian ($jd +intval ($days)-25569);
$gregorian = Strtotime ($gregorian);
$gregorian = Date ("y/m/d", $gregorian);
$myDate = explode (' \ \ ', $gregorian);
$MYDATESTR = Str_pad ($myDate [2],4, ' 0 ', str_pad_left). " -". Str_pad ($myDate [0],2, ' 0 ', str_pad_left)." -". Str_pad ($myDate [1],2, ' 0 ', str_pad_left). ($time? " 00:00:00 ": ' \ \ ');
return $gregorian;
}
return $time;
}
$val = ' 42930 '; What Excel Reads
$val = exceltimtetophp ($val);
$preg _date = '/^ (\d{4}) \/(0\d{1}|[ 1-9]{1}| | 1[0-2]) \ (0\d{1}|[ 1-9]{1}| [12]\d{1}|3[01]) $/'; Regular validation time: When the time is 2017/01/01 or 2017/1/1 or 2017/11/11 this all passes
$status _date = Trim ($val);
echo $status _date;
Preg_match ($preg _date, $status _date, $matches);
Var_dump ($matches);
The results are as follows:
PHP Read Excel time 42930 converted to time and then the regular verification time is passed