如何取得DZ数据库中的UNIX时间戳格式化
作者:我就是个世界
发表于:2008-01-02
用到的函数[b][color=#FF0000]data[/color][/b]
格式:
[code]data("Y-m-d",time()); [/code]
我的代码:[separator]
[code]<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpw = 'root';
$dbname = 'discuz2';
$dzbbs_tablepre = 'cdb_';
$dzss_tablepre = 'supe_';
$city_tablepre = 'cbc_';
$charset = 'utf-8';
/* 连接选择数据库 */
//$conn = mysql_connect( 'localhost', 'root', 'root')
$conn = mysql_connect( $dbhost, $dbuser, $dbpw)
or die( "Could not connect : " . mysql_error());
mysql_query("SET NAMES 'UTF8'");
mysql_select_db( $dbname,$conn) or die("Could not select database <br>");
/* 执行 SQL 查询 */
$query = 'SELECT * FROM '.$city_tablepre.'bizinfo,'.$city_tablepre.'comment where tuijian=1 order by digg desc limit 10';
$result = mysql_query($query, $conn) or die( "Query failed : " . mysql_error());
/* 定义变量 在 HTML 中打印结果 */
$biz_pingdian2='';
$date=date("m月d日Y年","$row["dateline"]");
while ($row = mysql_fetch_array($result,$conn)) {
$biz_pingdian2 = "<div class='tag_i1'><a href='userinfo.php?uid=".$row["uid"]."' class='blue_12b' target='_blank'>".$row["username"]."</a> 于 " .$date. " 点评了 <a href=bizinfo.php?bizid=".$row["bizid"]."' class='pd_12'>".$row[ "biz_name"]."</a><span class='ico'></span></div><div class='tag_i2x'><ul><li><a href='bizinfo.php?bizid=".$row["bizid"]."' class='nLink'>[查看详细]</a> <span class='jd_122'>".substr ($row[ 'content'], 0,50)."...</span></li><div style='padding-bottom:3px;'></div></ul></div>";
echo $biz_pingdian2;
}
/* 释放资源 */
mysql_free_result($result);
/* 断开连接 */
mysql_close();
?>[/code]
格式:
[code]data("Y-m-d",time()); [/code]
我的代码:[separator]
[code]<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpw = 'root';
$dbname = 'discuz2';
$dzbbs_tablepre = 'cdb_';
$dzss_tablepre = 'supe_';
$city_tablepre = 'cbc_';
$charset = 'utf-8';
/* 连接选择数据库 */
//$conn = mysql_connect( 'localhost', 'root', 'root')
$conn = mysql_connect( $dbhost, $dbuser, $dbpw)
or die( "Could not connect : " . mysql_error());
mysql_query("SET NAMES 'UTF8'");
mysql_select_db( $dbname,$conn) or die("Could not select database <br>");
/* 执行 SQL 查询 */
$query = 'SELECT * FROM '.$city_tablepre.'bizinfo,'.$city_tablepre.'comment where tuijian=1 order by digg desc limit 10';
$result = mysql_query($query, $conn) or die( "Query failed : " . mysql_error());
/* 定义变量 在 HTML 中打印结果 */
$biz_pingdian2='';
$date=date("m月d日Y年","$row["dateline"]");
while ($row = mysql_fetch_array($result,$conn)) {
$biz_pingdian2 = "<div class='tag_i1'><a href='userinfo.php?uid=".$row["uid"]."' class='blue_12b' target='_blank'>".$row["username"]."</a> 于 " .$date. " 点评了 <a href=bizinfo.php?bizid=".$row["bizid"]."' class='pd_12'>".$row[ "biz_name"]."</a><span class='ico'></span></div><div class='tag_i2x'><ul><li><a href='bizinfo.php?bizid=".$row["bizid"]."' class='nLink'>[查看详细]</a> <span class='jd_122'>".substr ($row[ 'content'], 0,50)."...</span></li><div style='padding-bottom:3px;'></div></ul></div>";
echo $biz_pingdian2;
}
/* 释放资源 */
mysql_free_result($result);
/* 断开连接 */
mysql_close();
?>[/code]
请发表您的评论