2011-11-07 81 views
0

如果有人能帮助我吗? PHP 我有这样的结果日期的在我的表EX:2011年11月7日,上午12:00 所以我需要这种结果EX的:11 07,2011,12,00 我怎么能转换本文日期到数字日期。文本日期数值日期,请

感谢如有:)

+0

它是更多钞票来更新我的MYTSQL表是 “2011年12月25日,5:31” forumat,进入“12月25日,2011,05,31 “格式与PHP。一些例子。再次感谢 – user1033986

回答

1

退房的strtotime()与PHP的日期(),您可能需要虽然有点格式化输出。

0
<?php 
$dateValue = '11 07, 2011'; 
date('m d, Y, H, m', strtotime($dateValue)); 
?> 

请注意,它目前的状态,你的日期值可能无法正确strtotime

+0

是不是H的权利应该是我? – Jeune

0

解析这是我对此采取:

function convert_date($date) { 
    $components = explode(" ",$date); 
    $time_component = array_pop($components); 
    $date_component = implode(array_slice($components, 0, 2)); 


    return date("m d, Y, ", strtotime($date_component)) . 
      date("H, i", strtotime($time_component)); 
} 

这里有一些运行:

$t1 = "November 07, 2011, 12:00"; 
    echo convert_date($t1) . "\n"; 

输出:11 07,2011,12,00

$t2 = "December 25, 2011, 5:31"; 
echo convert_date($t2); 

输出:12月25日,2011,05,31

+0

谢谢你们,太棒了。我现在得到它:) – user1033986

+0

它是更多钞票来更新我的MYTSQL表是 “2011年12月25日,5:31” forumat,与PHP “12月25日,2011,05,31” 的格式。一些例子。再次感谢 – user1033986

+0

据我所知,不是在格式你想,但你可以使用一些其他的变化在这里看到:http://dev.mysql.com/doc/refman/5.1/en/datetime.html – Jeune