DATETIME で部分文字列を実行しようとしています。DATETIME の値は、mysql を介してデータベースから取得されます。
例:
DATETIME: 2013-07-31 12:30:60 年: 2013 月: 07 日: 31 時間: 12 分: 30
以下のコードが機能しません。どうすればいいですか?
<?php
$sql = "SELECT * FROM auctionItem;";
// Write a statement to open a connection to MySQL server
$link = mysql_connect("localhost:3306", "root", "gfg");
// Write a statement to select the required database
mysql_select_db("KXCLUSIVE", $link);
// Write a statement to send the SQL statement to the MySQL server for execution and retrieve the resultset
$resultset = mysql_query($sql);
// Write a statement to close the connection
mysql_close($link);
$dateTime = $row["startTime"];
$year = substr($dateTime, 0,4);
$month = substr($dateTime, 5,7);
$day = substr($dateTime, 8,10);
$hour = substr($dateTime, 11,13);
$minute = substr($dateTime, 14,16);
echo "year " .$year."<br></br>";
echo "month " .$month."<br></br>";
echo "day " .$day."<br></br>";
echo "hour " .$hour."<br></br>";
echo "minute " .$minute."<br></br>";
?>