有没有一种简单的方法可以从一个非常简单的日期字符串中获取日期?
例如:
14 mar 2012
转换为:
Wed, 14 mar 2012
您应该熟悉DateTime
:
$str = "14 mar 2012";
$date = DateTime::createFromFormat("j M Y", $str);
$str = $date->format("D, j M Y");
$dateUnformated = '14 mar 2012';
$dateFormated = date("D, j M Y", strtotime($dateUnformated));