只是需要一点帮助。如何以相反的顺序显示 PHP 的日期输出?例如,如果我有这样的约会。
$date = date("Y-m-d"); //example output 2013-01-01
My expected output should be: 130-210-10 //01-01-2013
How can i do that?
如果可以更改参数在date()
中的顺序:
echo strrev(date('d-m-Y'));
如果无法更改date()
中参数的顺序:
echo implode('-', array_map('strrev', explode('-', $date)));
使用 strrev
$date = strrev(date("d-m-Y"));
请注意,我还如何根据预期的输出更改date
中参数的位置。
另请参阅:http://php.net/manual/en/function.strrev.php
Discover strrev():
$date = strrev(date("d-m-Y"));
使用strrev()
$date = strrev(date("Y-m-d"));