Posts Tagged strtotime
php的strtotime在处理am/pm时的一个BUG
今天在处理一个采集数据时发现采集到的时间是空的,到源网站看了一下,发现是有时间的。联想到之前一个am/pm的问题,然后就有了如下测试。
测试代码:
- $date = date('Y-m-d');
- $array = array('00:00am','00:00pm','00:01am','00:01pm', '01:01am','01:01pm','12:00am','12:00pm','12:01am','12:01pm');
- foreach ($array as $time) {
- echo $date . ' ' . $time.'<br />';
- echo strtotime($date . ' ' . $time).'<br />';
- echo date('Y-m-d H:i:s', strtotime($date . ' ' . $time)).'<br /><hr />';
- }
大家可以先自己想想预期的答案是什么,再往下看:
Read the rest of this entry »
近期评论