I'm trying to do some basic date and timestamp operations in PHP and have been getting unexpected results. I'm trying to get a timestamp with just the year, month, and day of the month (i.e. the timestamp of a date at 12:00 A.M.) of the existing timestamp $startDate. It was changing the date as well, though, as can be seen in the following code.
$startDateString = date("Y-M-j", $startDate);
$startDateTimestamp = strtotime($startDateString);
echo "$startDate == $startDateTimestamp ?<br>";
echo date("Y-M-j", $startDate)." == ".date("Y-M-j", $startDateTimestamp)." ?<br>";
This gives me the following output:
1299299589 == 1298952000 ?
2011-Mar-4 == 2011-Feb-28 ?
While I wouldn't expect the timestamps to be the same (as $startDate is not necessarily at 12:00 A.M.), I can't see how the calendar dates aren't the same. What am I doing wrong?