The usage method is exactly the same as the old function.
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.
http://www.bkjia.com/PHPjc/969963.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/969963.htmlTechArticlephp realizes compatibility with Unix timestamp conversion function after 2038. This article mainly introduces php to realize compatibility with Unix after 2038. The timestamp conversion function is used in the same way as the previous function. It is very practical...