Exemplo n.º 1
0
function timediff($starttime, $end_time = null)
{
    date_Default_TimeZone_set("PRC");
    $starttime = strtotime($starttime);
    if (!$end_time) {
        $end_time = strtotime(date("Y-m-d H:i:s"));
    }
    if ($starttime >= $end_time) {
        return "1秒";
    }
    $timediff = $end_time - $starttime;
    //var_dump($timediff);
    $days = intval($timediff / 86400);
    $remain = $timediff % 86400;
    $hours = intval($remain / 3600);
    $remain = $remain % 3600;
    $mins = intval($remain / 60);
    $secs = $remain % 60;
    if ($mins > 0) {
        $res .= $mins . "分";
    }
    if ($secs > 0) {
        $res .= $secs . "秒";
    }
    if ($hours > 0) {
        $res = $hours . "小时";
    }
    if ($days > 0) {
        $res = $days . "天";
    }
    if (!$res) {
        $res = "1秒";
    }
    return $res;
}
Exemplo n.º 2
0
<?php
//作者:Knight
date_Default_TimeZone_set("PRC");
require_once("fun.php");
require_once("config.php");

$biaoti = $_POST['biaoti'];
$neirong = $_POST['neirong'];
$touxiang = $_POST['touxiang'];
$nicheng = $_POST['nicheng'];
$page = $_GET['page'];
//插入数据库
if($biaoti)
{
	$time = time();
	$sql = "insert into lyb set biaoti='$biaoti',neirong='$neirong',touxiang='$touxiang',time='$time',nicheng='$nicheng'";
	mysql_query("SET NAMES 'utf8'"); 
 	$rs = mysql_query($sql);
	if($rs)
	{
		echo "<meta http-equiv=refresh content='0; url=index.php'>"; 

	}
}

//删除留言
if($_GET['pd']=='del')
{
	$id = $_GET['id'];
	$sql = "delete from lyb where id='$id'";
		mysql_query("SET NAMES 'utf8'");