Php is compatible with the Unix timestamp conversion function after January 1, 2038. tutorial on 2038unix_PHP

Source: Internet
Author: User
Php is compatible with the Unix timestamp conversion function after January 1, 2038, 2038 unix. Php is compatible with the Unix timestamp conversion function after January 1, 2038. the 2038unix usage is exactly the same as that of the old function. copy the code as follows: functionfun_strtotime ($ var10, $ var20) {if (! $ Var2 php is compatible with Unix timestamp conversion functions after January 2038, 2038 unix

The usage is exactly the same as that of 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 help you learn php.

Returns the unixtime stamp conversion after January 1, 2038. the 2038unix usage is exactly the same as that of the old function. the code is as follows: function fun_strtotime ($ var1 = 0, $ var2 = 0) {if (! $ Var2...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.