|
 |
|
อยากสอบถามเรื่อง Datetime ใน php5 หน่อยครับ Help me plz |
|
 |
|
|
 |
 |
|
Code (PHP)
public function getAllSms_message() {
$stmt = mysqli_prepare($this->connection, "SELECT * FROM $this->tablename");
$this->throwExceptionOnError();
mysqli_stmt_execute($stmt);
$this->throwExceptionOnError();
$rows = array();
mysqli_stmt_bind_result($stmt, $row->requestid, $row->requestdate, $row->callerid, $row->sender, $row->message, $row->msisdn, $row->phonestatus, $row->retry, $row->status, $row->chkstatus, $row->senttime, $row->deliverystatus);
while (mysqli_stmt_fetch($stmt)) {
if($row->requestdate == null)
{
$row->requestdate = null;
}
else
{
$row->requestdate = new DateTime($row->requestdate);
}
if($row->senttime == null)
{
$row->senttime = null;
}
else
{
$row->senttime = new DateTime($row->senttime);
}
$rows[] = $row;
$row = new stdClass();
mysqli_stmt_bind_result($stmt, $row->requestid, $row->requestdate, $row->callerid, $row->sender, $row->message, $row->msisdn, $row->phonestatus, $row->retry, $row->status, $row->chkstatus, $row->senttime, $row->deliverystatus);
}
mysqli_stmt_free_result($stmt);
mysqli_close($this->connection);
return $rows;
}
คำถาม
จากบรรทัดนี้ $row->requestdate = new DateTime($row->requestdate);
ผมไม่อยากใช้ DateTime สามารถใช้ date มาแทนได้อย่างไรครับ
สาเหตุที่ไม่ใช้เพราะใช้ php ver เก่ากว่า เลยใช้ class DateTime ไม่ได้ครับ
รบกวนด้วยครับ
ขอบคุณครับ
Tag : PHP

|
|
 |
 |
 |
 |
Date :
2012-02-08 16:24:30 |
By :
LunaziA |
View :
933 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ใช้ date
$date = date("Y-m-d") ;// 2012-02-08
|
 |
 |
 |
 |
Date :
2012-02-08 16:54:52 |
By :
randOmizE |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 02
|