我有这个PHP代码:
$monthNum = sprintf("%02s", $result["month"]);
$monthName = date("F", strtotime($monthNum));
echo $monthName;
但这是返回December而不是August。
$result["month"]等于8,因此sprintf函数要添加一个0使其08。
strtotime不知道“ 8”是什么意思。strtotime解析完整的时间戳,例如“ 2012-05-12 08:43:12”。在这种情况下,“ 8”是什么意思?
echo date( "F", time() );?例如,echo date( "F", strtotime("2019-03-09") );将输出“ March”
strtotime不知道您要做什么。另外,也可以使用类似这样的开关。