-3
echo date('Y-m-d',strtotime('02-12-13'));

英語形式なので

期待される出力:2013-12-02

私の出力:2002-12-13

誰が何が起こっているのか知っていますか?

4

3 に答える 3

1

マニュアルで指定されているように、「xx-xx-xx」は「yy-mm-dd」として解釈されます: http://www.php.net/manual/en/datetime.formats.date.php

于 2013-09-19T17:31:01.227 に答える
0

You have to use date_parse_from_format () and use the returned array to build the correct format.

http://de3.php.net/manual/en/function.date-parse-from-format.php

however, maybe it is better to just format your original us date string with simple string manipulation.

Convert UK date to US date in PHP with different separator

list($date,$month,$year) = sscanf("01/01/2012", "%d/%d/%d");
echo "$month-$date-$year";
于 2013-09-19T17:38:28.477 に答える