<?php
$string = '18 hours and 14 minutes ago';
$regex = '#\d+\s\w+#';
preg_match_all($regex, $string, $matches);
$date = new DateTime();
echo 'current date = '.$date->format('Y-m-d H:i:s')."\n";
foreach ($matches[0] as $modify) {
$date->modify('-'.$modify);
}
echo 'modified date = '.$date->format('Y-m-d H:i:s');
- Output for 7.0.0 - 7.0.23, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33, 8.0.0 - 8.0.12, 8.0.14 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
- current date = 2017-09-06 17:16:39
modified date = 2017-09-05 23:02:39
- Output for 7.3.32 - 7.3.33, 8.0.13
- current date = 2017-09-06 15:16:39
modified date = 2017-09-05 21:02:39
preferences:
122.88 ms | 401 KiB | 224 Q