PHP function strftime() working in part of code but not other part?

Why is strftime() not working in part of my code?

In my page i have

just for testing that strftime works like it should

/// i comment the next 2 lines out when i run the page as this is just debugging
$date =‘Nov 02, 2009’;
echo strftime("%Y-%m-%d",strtotime($date));
//returns ‘2009-11-02’

// this worked as expected
######################################…

But further down where I am running the function after getting data via cURL the same thing fails.
//$receipt[0] - returned ‘Nov 02 , 2009’ (See master $receipt array below)had extra white spaces so i did the next str_replace below to make it return ‘Nov 02, 2009’ - this works

$date = trim(str_replace(’ ', ‘’, $receipt[0]));
//date is not ‘Nov 02,2009’
$date = strftime("%Y-%m-%d",strtotime($date));

foreach ($receipts as $receipt){
$date = trim(str_replace(’ ', ‘’, $receipt[0])); // fixed extra whitespaces now returns ‘Nov 02, 2009’
echo $date; returns ‘Nov 02, 2009’
$date = strftime("%Y-%m-%d",strtotime($date));
echo $date; // returns ‘1969-12-31’ // This is not expected results
$codeDesc = mysql_real_escape_string($receipt[1]);
$amount = mysql_real_escape_string($receipt[3]);
}

###############################Info to help debug###################################…
PHP Version 5.3.1
Apache/2.2.14 (Win32) DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l PHP/5.3.1

date:
date/time support enabled
“Olson” Timezone Database Version 2009.18
Timezone Database internal
Default timezone America/Chicago

Notice the dates in the array with extra spacing
--------------------------------------… Just for Ref-------------------------------------
Array ( [0] => Array ( [0] => Nov 02 , 2009 [1] => MONEY ORDER/PAYMENT [2] => 17480965680 [3] => $500.00 [4] => 000000 ) [1] => Array ( [0] => Dec 14 , 2009 [1] => MONEY ORDER/PAYMENT [2] => 17483211617 [3] => $231.48 [4] => 000000 ) [2] => Array ( [0] => Dec 14 , 2009 [1] => MONEY ORDER/PAYMENT [2] => 17483211628 [3] => $231.48 [4] => 000000 ) [3] => Array ( [0] => Jan 25 , 2010 [1] => MONEY ORDER/PAYMENT [2] => 9478704011 [3] => $231.58 [4] => 000000 ) [4] => Array ( [0] => Feb 19 , 2010 [1] => EMPLOYER CHECK/ONE D [2] => 6648 [3] => $231.48 [4] => 000000 ) [5] => Array ( [0] => Mar 12 , 2010 [1] => DEBTOR PAYMENT REMIT [2] => 7512 [3] => $231.48 [4] => 000000 ) [6] => Array ( [0] => Mar 12 , 2010 [1] => DEBTOR PAYMENT REMIT [2] => 7513 [3] => $231.48 [4] => 000000 ) [7] => Array ( [0] => Apr 15 , 2010 [1] => EMPLOYER CHECK/ONE D [2] => 7595 [3] => $231.48 [4] => 000000 ) [8] => Array ( [0] => Apr 15 , 2010 [1] => EMPLOYER CHECK/ONE D [2] => 7596 [3] => $231.48 [4] => 000000 ) [9] => Array ( [0] => May 03 , 2010 [1] => DEBTOR PAYMENT REMIT [2] => 7678 [3] => $231.48 [4] => 000000 ) [10] => Array ( [0] => May 03 , 2010 [1] => DEBTOR PAYMENT REMIT [2] => 7679 [3] => $231.48 [4] => 000000 ) [11] => Array ( [0] => Jun 01 , 2010 [1] => DEBTOR PAYMENT REMIT [2] => 7755 [3] => $231.48 [4] => 000000 ) [12] => Array ( [0] => Jun 01 , 2010 [1] => DEBTOR PAYMENT REMIT [2] => 7757 [3] => $231.48 [4] => 000000 ) [13] => Array ( [0] => Jul 19 , 2010 [1] => EMPLOYER CHECK/ONE D [2] => 7838 [3] => $231.48 [4] => 000000 ) [14] => Array ( [0] => Jul 19 , 2010 [1] => EMPLOYER CHECK/ONE D [2] => 7877 [3] => $231.48 [4] => 000000 ) [15] => Array ( [0] => Sep 20 , 2010 [1] => EMPLOYER CHECK/ONE D [2] => 8058 [3] => $231.48 [4] => 000000 ) [16] => Array ( [0] => Sep 20 , 2010 [1] => EMPLOYER CHECK/ONE D [2] => 8059 [3] => $231.48 [4] => 000000 ) [17] => Array ( [0] => Sep 20 , 2010 [1] => EMPLOYER CHECK/ONE D [2] => 8060 [3] => $231.48 [4] => 000000 ) )

After doing str_replace, you end up with Nov02,2009 with no spaces.

Sponsor our Newsletter | Privacy Policy | Terms of Service