is exactly the same as the old function.
Copy code The code is as follows:
function fun_strtotime($var1=0,$var2=0){
If(!$var2){
$var2 = $var1;
$var1 = 0;
}
If(is_numeric($var2)){
$var2 = '@'.$var2;
}
Try{
$date = new DateTime($var2);
$date->setTimezone(new DateTimeZone(date_default_timezone_get()));
}catch(Exception $e){ $date = 0;}
If(is_object($date)){
if($var1)
$date->modify($var1);
return $date->format('U');
}else{
return 0;
}
}
function fun_date($var1=0,$var2=0){
If(!$var2){
$var2 = $var1;
$var1 = 'Y-m-d H:i:s';
}
Try{
$date = new DateTime('@'.$var2);
$date->setTimezone(new DateTimeZone(date_default_timezone_get()));
}catch(Exception $e){ $date = 0;}
If(is_object($date)){
return $date->format($var1);
}else{
return '';
}
}
The above is all the content described in this article. I hope it will be helpful to everyone learning php.