|
|
|
สอบถามครับ คือผมต้องการวันที่ที่ได้ฐานข้อมูลแสดงแค่เฉพาะ ชั่วโมง ครับ |
|
|
|
|
|
|
|
ปกติตอนดึงค่าวันที่จากฐานข้อมูลมันจะขึ้นแบบนี้ครับ 2018-07-13 00:00:00 แต่ผมต้องการ 00:00:00 พี่ๆช่วยแนะนำหน่อยครับว่าพอจะทำยังไงได้บ้าง
Code (PHP)
<?php require_once('../../../Connections/TempH.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$maxRows_Dataformdatabase = 24;
$pageNum_Dataformdatabase = 4;
if (isset($_GET['pageNum_Dataformdatabase'])) {
$pageNum_Dataformdatabase = $_GET['pageNum_Dataformdatabase'];
}
$startRow_Dataformdatabase = $pageNum_Dataformdatabase * $maxRows_Dataformdatabase;
mysql_select_db($database_TempH, $TempH);
$query_Dataformdatabase = "SELECT * FROM temp";
$query_limit_Dataformdatabase = sprintf("%s LIMIT %d, %d", $query_Dataformdatabase, $startRow_Dataformdatabase, $maxRows_Dataformdatabase);
$Dataformdatabase = mysql_query($query_limit_Dataformdatabase, $TempH) or die(mysql_error());
$row_Dataformdatabase = mysql_fetch_assoc($Dataformdatabase);
if (isset($_GET['totalRows_Dataformdatabase'])) {
$totalRows_Dataformdatabase = $_GET['totalRows_Dataformdatabase'];
} else {
$all_Dataformdatabase = mysql_query($query_Dataformdatabase);
$totalRows_Dataformdatabase = mysql_num_rows($all_Dataformdatabase);
}
$totalPages_Dataformdatabase = ceil($totalRows_Dataformdatabase/$maxRows_Dataformdatabase)-1;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="refresh" content="10; url="<?php echo $_SERVER['temp_dw']; ?>">
<title>Temperature</title>
<script type="text/javascript">
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
</script>
<style type="text/css">
body,td,th {
color: #000;
font-size: 15px;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
}
body {
background-image: url();
}
</style>
</head>
<body onload="MM_preloadImages('images/images/15_03.jpg','images/images/15_05.jpg','images/images/15_07.jpg')">
<table width="1024" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td colspan="3" align="center"><img src="images/images/15_01.jpg" width="1024" height="231" /></td>
</tr>
<tr>
<td width="300" height="0" valign="top"> </td>
<th width="724" colspan="2" rowspan="4" align="left" valign="top" bgcolor="#FFFFFF"><p> </p>
<table width="500" border="0" align="center">
<tr>
<td width="166" height="31" bgcolor="#0099FF"><div align="center"><font color= "#FFFFFF"><font size ="5px"> Date </font></font></div></td>
<td bgcolor="#0099FF"><div align="center"><font color= "#FFFFFF"><font size ="5px"> Temperature</font></font></div></td>
<td width="166" bgcolor="#0099FF"><div align="center"><font color= "#FFFFFF"><font size ="5px"> Humidity</font></font></div></td>
</tr>
<?php do { ?>
<?
$statust = $row_Dataformdatabase['Temperature'];
$statush = $row_Dataformdatabase['Humidity'];
{
if($statust < "26") $bg="#E0FFFF"; // ต่ำกว่า 26 สีปกติ
if($statust >= "26") $bg="#FF3333"; // สูงกว่า 26 สีแดง
if($statush < "50") $bgh="#E0FFFF"; // ต่ำกว่า 26 สีปกติ
if($statush >= "50") $bgh="#FF3333"; // สูงกว่า 26 สีแดง
}
?>
<tr>
<td align="center" bgcolor="#E0FFFF"><?php echo $row_Dataformdatabase['Date']; ?></td>
<td align="center" bgcolor="<?=$bg;?>"><?php echo $row_Dataformdatabase['Temperature']; ?></td>
<td align="center" bgcolor="<?=$bgh;?>"><?php echo $row_Dataformdatabase['Humidity']; ?></td>
</tr>
<?php } while ($row_Dataformdatabase = mysql_fetch_assoc($Dataformdatabase)); ?>
</table>
<table width="300" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="center" valign="top"><p><a href="../../../Charts/7/C617_1 (13).php"><img src="../../../images/business-growth-chart-3079.png" width="50" height="50" /></a></p>
<p><a href="../../../Charts/7/C617_1 (13).php">กราฟแสดงสถานะ</a></p></td>
</tr>
</table>
<p> หมายเหตุ : อุหณภูมิ ไม่ควรเกิน 26 °C </p>
<p> ถ้าเกินกว่ากำหนดตารางจะเป็นสีแดง </p></th>
</tr>
<tr valign="top"></tr>
<tr valign="top"></tr>
<tr valign="top">
<th height="0" valign="top"><table width="300" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top"><a href="../../../index.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image4','','images/images/15_03.jpg',1)"><img src="images/15_03.jpg" width="322" height="103" id="Image4" /></a></td>
</tr>
<tr>
<td valign="top"><a href="../../../หน้าแรก.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image5','','images/images/15_05.jpg',1)"><img src="images/15_05.jpg" width="322" height="103" id="Image5" /></a></td>
</tr>
<tr>
<td valign="top"><a href="../../../ผู้จัดทำ.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image7','','images/images/15_07.jpg',1)"><img src="images/15_07.jpg" width="322" height="104" id="Image7" /></a></td>
</tr>
<tr>
<td valign="top"> </td>
</tr>
</table></th>
</tr>
<tr>
<td colspan="3" align="center"><img src="images/ex1---Copy_02.jpg" width="1029" height="93" /></td>
</tr>
</table>
<p> </p>
</body>
</html>
<?php
mysql_free_result($Dataformdatabase);
?>
Tag : PHP, MySQL
|
|
|
|
|
|
Date :
2018-08-07 10:35:14 |
By :
knesza29 |
View :
577 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ลองดูนะครับ
Code (PHP)
<?php
//ดึงมาจากฐานข้อมูลเอานะครับ
$date = '2014-06-21 13:40:31';
$dataArray = explode(' ', $date);
echo "เวลา คือ ", $dataArray[1];
?>
|
|
|
|
|
Date :
2018-08-07 10:39:10 |
By :
nobetaking |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
echo date("H:i:s", strtotime('2018-07-13 00:00:00'));
read more
date : http://php.net/manual/en/function.date.php
strtotime : http://php.net/strtotime
|
|
|
|
|
Date :
2018-08-07 12:01:32 |
By :
DK |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|