Php strtotime with different result on 64-bit

I have a php function called _to_unix_timestamp () code:

function _to_unix_timestamp($param){
    if ($timestamp = strtotime($param)){
        return $timestamp;
    }
    return (int) $param;
}

The code works on my development server (32 bit),
but when I deploy my application on a production server (64 bit), the
exit from this function is slightly different

Example

 // expected to be "int(1306400175)" but the output is "int(-56632154432)" 
 var_dump(_to_unix_timestamp("1306400175"));

on my development server, the output is int (1306400175)
but on the production server the output is int (-56632154432)

development server information only (32 bit) =
Linux glustervm 2.6.18-164.el5xen # 1 SMP Thu Sep 3 04:47:32 EDT 2009 i686 i686 i386 GNU / Linux
PHP 5.2.9

(64 ) =
Linux minicapella 2.6.18-164.15.1.el5.centos.plusxen # 1 SMP Wed 17 20:32:20 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux
PHP 5.2.13

//append "> 0"
if ($timestamp = strtotime($param) > 0){

, , ?


-rizkyabdilah

+3
1

Strtotime , , , - . , "1306400175", YEAR-MONTH-DAY-HOUR -..., , , , , -, , , .

, , , , strtotime ( "1400" ), , 14:00. , 32, 64 , , , , , , PHP_INT_MAX ( , , ), 32 64 PHP.

, , , strtotime:

if (!is_numeric($param) && ($timestamp = strtotime($param)) {

, , , - / (, "2011-04-08 14:00" ) .

+3

All Articles