2014-02-11 54 views
0

我需要格式化日期時間到使用PHP的特定日期格式。格式在php中的日期時間

現在日期格式 2014年2月10日9時32分24秒

我需要的格式 2014年2月10日

error is :Parse error: syntax error, unexpected '$ModifiedDate' (T_VARIABLE), expecting ',' or ';' in ................. line

在這裏,我試圖像這樣

<?php 
include(config.php); 

$sql = "SELECT Id,Title,description,Image,Category,ModifiedDate from News WHERE ISActive=true"; 

$query = mysql_query($sql); 
if(mysql_num_rows($query)>0){ 


while($test = mysql_fetch_array($query)) 
{ 
        $Mod = $test['ModifiedDate']; 
     $ModifiedDate = date_format($Mod, 'yyyy/MM/dd'); 


     echo"<td><font color='black'>"$ModifiedDate"</font></td>"; 

    } 

    } 

    else 
    { 
echo "No Records"; 
    } 
    ?> 

回答

3

你忘了連接變量。做這樣的

echo"<td><font color='black'>".$ModifiedDate."</font></td>"; 
          //^-----  ^----- Add those dots ! 
0

試試這個代碼:

$ModifiedDate = date_format($Mod, 'Y/m/d'); 
0

以下格式使用,

date_format($Mod, 'YY/MM/DD');