我正在尝试 t0 在 DATETIME 上执行子字符串,DATETIME 的值是通过 mysql 从数据库中检索的。
例子:
日期时间:2013 年 7 月 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>";
?>