如何从具有特殊条件的数据库中获取数组中的数据


How to get data in array from database with special condition

我有下面的数组示例。URL是从数据库中提取的,但数据格式应该是指定格式的当前日期和时间。

示例阵列

$array = array(
array('permalink' => 'http://www.myweb.com/someurl1', 
'updated' => '2012-08-11T04:08:53+01:00'),
array('permalink' => 'http://www.myweb.com/someurl2', 
'updated' => '2012-09-11T04:08:53+01:00'));

谢谢你的帮助。。。

您可以使用DATE_FORMAT()和mysql更改SQL语句。

http://www.w3schools.com/sql/func_date_format.asp

如果你想通过PHP来实现这一点,请将字符串转换为日期,然后格式化。例如:

$date = date("Y-m-d",strtotime($date_in_string_format));

http://php.net/manual/en/datetime.formats.date.php

使用

$updated = date('Y-m-d'TH:i:sO');