i've got code
$dss='2011 04 28 10:00:45';
echo date('Y', strtotime($dss));
it display 1970- why?
it display 1970- why?
Becuase the format YYYY MM DD HH:MM:SS isn't one of the formats that strtotime accepts. In particular, it's failing to find a valid date string.
If you're using PHP 5.3 or better, look at DateTime::createFromFormat(), which takes a date-formatted string and creates a new DateTime object based on that format.
If you're stuck on a lower version of PHP, your "best" choice is the clunky strptime.
Or you can just stick dashes between the YYYY and MM and then between the MM and the DD, yielding YYYY-MM-DD, a perfectly cromulent format.
Wrong answer before...was -1 worthy...I'm now climbing backwards onto the donkey, putting the pail on my head, and leaving town.
strtotime returns either false or -1 based on the PHP version being used.)