更改时间格式[关闭]

sorry for my English. I’m trying this:

$startTime = strtotime('2013-12-23');
$endTime = strtotime('2013-12-31');

for ($i = $startTime; $i <= $endTime; $i = $i + 86400) {

    echo date('m.d.Y', $i)."<br/>";

    echo date('d-m-Y', strtotime(date('m.d.Y', $i)))."<br />";

}

So, why I get:

12.23.2013
01-01-1970
12.24.2013
01-01-1970
...

If I try

echo date('m.d.Y', $i)."<br/>";
echo date('d-m-Y', $i)."<br/>";

It’s ok, I get correct result.

Thanks You.

The m.d.Y is a format strtotime can not parse. Use another format ( eg 'c' ) to get it working.

This is from the php manual

Note: Dates in the m/d/y or d-m-y formats are disambiguated by looking at the separator between the various components: if the separator is a slash (/), then the American m/d/y is assumed; whereas if the separator is a dash (-) or a dot (.), then the European d-m-y format is assumed. To avoid potential ambiguity, it's best to use ISO 8601 (YYYY-MM-DD) dates or DateTime::createFromFormat() when possible.

strtotime doesn't take the format 'm.d.Y'

You can see in the docs what it does accept.