使用此代码:
<?php
$timing_strings =array(1=>'just now', 2=>'3 minutes ago', 3=>'3 weeks ago');
$new_arr=array();
foreach ($timing_strings as $time) {
$new_arr[] = check_time($time);
}
echo "<pre>";
print_r($new_arr);
echo "</pre>";
exit;
function check_time($time) {
if (strpos($time,'just now') !== false) {
return date("Y-m-d H:i:s",strtotime('now'));
}elseif (strpos($time,'minutes ago') !== false) {
return date("Y-m-d H:i:s",strtotime('-'.(int)$time.' minutes'));
}elseif (strpos($time,'weeks ago') !== false) {
return date("Y-m-d H:i:s",strtotime('-'.((int)$time*7).' days'));
}
}
输出
Array
(
[0] => 2013-10-04 18:47:44
[1] => 2013-10-04 18:44:44
[2] => 2013-09-13 18:47:44
)