Php strotime不输出任何内容
我尝试了以下方法Php strotime不输出任何内容,php,Php,我尝试了以下方法 echo "Pre order date > $pre_order_close_date"; $pre_order_unix_time = strtotime($pre_order_close_date); echo "Unix time is > $pre_order_unix_time"; 结果是 Pre order date > 31 Jan 2016Unix time is > 然后我尝试了下面的方法,看看我的日期格式是否合适 ec
echo "Pre order date > $pre_order_close_date";
$pre_order_unix_time = strtotime($pre_order_close_date);
echo "Unix time is > $pre_order_unix_time";
结果是
Pre order date > 31 Jan 2016Unix time is >
然后我尝试了下面的方法,看看我的日期格式是否合适
echo "Pre order date > $pre_order_close_date";
$pre_order_unix_time = strtotime("31 Jan 2016");
echo "Unix time is > $pre_order_unix_time";
结果是
Pre order date > 31 Jan 2016Unix time is > 1454198400
看起来,如果我直接输入字符串,它会正常工作,但如果我使用变量代替2016年1月31日,它不会输出任何内容
我在这里会做错什么
谢谢你的帮助强>
**我如何获得我的预订单日期**
$get_内容具有此值
<p>Retail Price: USD 42<br />
<span class="il">Pre</span>–<span class="il">Order</span> Price: USD 40<br />
<span class="il">Pre</span>–<span class="il">Order</span> <span class="il">Close</span> <span class="il">Date</span>: 31 Jan 2016<br />
Release <span class="il">Date</span>: 1Q 2016</p>
$get_content_explode = explode("\n",$get_content);
foreach($get_content_explode as $gce)
{
if(strstr(strtolower($gce),"close"))
{
$pre_order_close_arr = explode(":",$gce);
$pre_order_close_date = trim($pre_order_close_arr[1]);
}//end if gce
}//end foreach
零售价:42美元
前&8211;订单价格:40美元
前&8211;订单截止日期:2016年1月31日
发布日期:2016年第1季度
$get\u content\u explode=explode(“\n,$get\u content”);
foreach($get\u content\u爆炸为$gce)
{
if(strstr(strtolower($gce),“关闭”))
{
$pre_order_close_arr=爆炸(“:”,$gce);
$pre_order_close_date=修剪($pre_order_close_arr[1]);
}//如果普通中等教育结束
}//端部foreach
$get\u content
包含HTML标记。使用strip_tags()
将其删除
$get_content_explode = explode("\n", str_replace(' ', ' ', (strip_tags($get_content))));
$get\u content
包含HTML标记。使用strip_tags()
将其删除
$get_content_explode = explode("\n", str_replace(' ', ' ', (strip_tags($get_content))));
我怀疑
$pre\u order\u close\u date
包含一些HTML标记。当你查看网页时,你看不到它。尝试使用View Source查看真正的内容。在这里可以正常工作:@Barmar如何确保我看到的文本将转换为php的字符串,以便我的strotime可以正常工作。您需要首先修复设置变量所使用的任何内容。变量来自何方?我注意到您在
之后打印了一个额外的空格,它是否以
开头?我怀疑$pre\u order\u close\u date
包含一些HTML标记。当你查看网页时,你看不到它。尝试使用View Source查看真正的内容。在这里可以正常工作:@Barmar如何确保我看到的文本将转换为php的字符串,以便我的strotime可以正常工作。您需要首先修复设置变量所使用的任何内容。变量来自何方?我注意到您在>
之后打印了一个额外的空格——它是以
开头的吗?我不知道为什么,但它在我这方面仍然不起作用,有没有机会调试或查看此类问题的错误日志?请尝试var\u dump(htmlentities($get\u content))
查看$get\u content
.string(17)“2016年1月31日”中的所有内容如果我var dump$pre\u order\u close\u date如果我var dump get\u content,它会返回相同的内容,只是还没有爆炸。我告诉过你使用htmlentities()
,这样你就可以看到变量中的所有标记。我不知道为什么,但它在我这方面仍然不起作用,有机会调试或查看此类问题的错误日志吗?试试var\u dump(htmlentities($get_content))
要查看$get_content
.string(17)“2016年1月31日”如果我var dump$pre_order\u close_date如果我var dump get_content,它会返回相同的内容,只是还没有分解。我告诉过你使用htmlentities()
,这样你就可以看到变量中的所有标记。