PHP implementation compatible with the UNIX timestamp conversion function after 2038 years, 2038unix
Use the same method as the old function.
Copy the Code code as follows:
function Fun_strtotime ($var 1=0, $var 2=0) {
if (! $var 2) {
$var 2 = $var 1;
$var 1 = 0;
}
if (Is_numeric ($var 2)) {
$var 2 = ' @ '. $var 2;
}
try{
$date = new DateTime ($var 2);
$date->settimezone (New Datetimezone (Date_default_timezone_get ()));
}catch (Exception $e) {$date = 0;}
if (Is_object ($date)) {
if ($var 1)
$date->modify ($var 1);
return $date->format (' U ');
}else{
return 0;
}
}
function Fun_date ($var 1=0, $var 2=0) {
if (! $var 2) {
$var 2 = $var 1;
$var 1 = ' y-m-d h:i:s ';
}
try{
$date = new DateTime (' @ '. $var 2);
$date->settimezone (New Datetimezone (Date_default_timezone_get ()));
}catch (Exception $e) {$date = 0;}
if (Is_object ($date)) {
return $date->format ($var 1);
}else{
Return ';
}
}
The above is the whole content of this article, I hope to learn PHP to help you.
http://www.bkjia.com/PHPjc/969483.html www.bkjia.com true http://www.bkjia.com/PHPjc/969483.html techarticle The PHP implementation is compatible with the UNIX timestamp conversion function after 2038 years, and the 2038unix method is identical to the old function. Copy the code as follows: function Fun_strtotime ($var 1=0, $var 2=0) {if (! $var 2 ...