日期未正确存储在Cookie中

I stored this date in a cookie:

Tue Jun 26 2012 15:38:41 GMT+0200 (CEST)

and now I need to print it in this form:

06/26/2012 15:38

So I write this code:

echo $_COOKIE['date'];
echo date('m/d/Y g:i A', strtotime($_COOKIE['date'])); 

but I get this:

Tue Jun 26 2012 15:38:41 GMT 0200 (CEST)
12/31/1969 7:00 PM

instead of:

 06/26/2012 15:38

Why?

strtotime does not seem to understand the date format, you can try to parse it with DateTime::createFromFormat or you can try to store it in another format

Perhaps its easier to store the timestamp in the cookie and not the date string.

$_COOKIE['date'] = time();

and then read it direct to the date function.

i have tried this:

<?php
setcookie('date', time());
var_dump($_COOKIE);
echo date('m/d/Y g:i A', $_COOKIE['date']);
?>

and the result is: 06/25/2012 6:13 PM

Because strtotime is not recognizing the date format you are using.