I was wondering if there is a way, using PHP, to change this date format: 01.08.86 (January 8, 1986) to this format: 1.8.86.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
<?php
$date = "01.08.86";
$unix = strtotime($date);
echo date('n.j.y', $unix);
回答2:
How about a regex based solution:
$str = '01.08.86';
$a = array('/^0(\d+)/','/\.0(\d+)/');
$b = array('\1','.\1');
$str = preg_replace($a,$b,$str);
// $str is now '1.8.86'