⑴ php的問題,以下代碼里當前時間和發布時間沒有識別年份這個錯誤不知怎麼修改請高手指點,萬分感謝!
你這個代碼是js的= =
js獲取當前時間戳為Math.round(new Date().getTime()/1000) 用這個時間戳跟你的起始結束時間戳做下對比就可以了。
關於php時間的判定時間戳如下。
$start_time=1517414400;//2018年2月1日0點0分0秒的時間戳
$end_time=1543593600;//2018年12月1日0點0分0秒的時間戳
$start_time>time()?print('活動尚未開始'):'';
$end_time<time()?print('活動已結束'):'';
⑵ 急!php如何獲取當前頁面運行的時間
<script>
function CurentTime()
{
var now = new Date();
var year = now.getFullYear(); //年
var month = now.getMonth() + 1; //月
var day = now.getDate(); //日
var hh = now.getHours(); //時
var mm = now.getMinutes(); //分
var ss = now.getSeconds(); //秒
var clock = year + "-";
if(month < 10)
clock += "0";
clock += month + "-";
if(day < 10)
clock += "0";
clock += day + " ";
if(hh < 10)
clock += "0";
clock += hh + ":";
if (mm < 10) clock += '0';
clock += mm + ":";
if (ss < 10) clock += '0';
clock += ss;
return(clock);
}
document.write(CurentTime());
</script>
⑶ 怎樣用PHP顯示動態時間
php動態顯示時間,我們需要做的是獲取到當前的時間戳,然後在通過innerHTML實時的顯示到網頁中,toLocaleString就是一個時間戳,按照一定格式顯示,這里舉個例子:
<table>
<tr bgcolor="#FFFFFF">
<td>當前時間:</td>
<td id="CurrentTime"></td>
<script type="text/javascript">
function changetime(){
var ary = Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六");
var Timehtml = document.getElementById('CurrentTime');
var date = new Date();
Timehtml.innerHTML = ''+date.toLocaleString()+' '+ary[date.getDay()];
}
window.onload = function(){
changetime();
setInterval(changetime,1000);
}
</script>
</tr>
</table>
⑷ php中如何刷新驗證碼
我做的一個簡單的登錄界面有刷新驗證碼還有注冊功能 希望對LZ有幫助
這個是登錄界面 land.php
<?php
@include_once('global.php');
session_start();
$user = $_POST['username'];
$sql = sprintf("select * from `p_admin` where `username` = '%s'",$user);
//echo $sql;
$query = $db->query($sql);//調用golbal裡面的$db類
$fetch = $db->fetch_array($query);
if($_POST['sccode']==$_SESSION['rand']){
$state = $fetch ? md5($_POST['password'].$extra)==$fetch['password']:FALSE;//是否登錄成功 如果失敗了返回為空echo $state沒有結果
if(!$state)
echo"<script language=javascript>alert('用戶名或密碼錯誤');</script>";
else {
$_SESSION['id'] = $fetch['m_id'];
$_SESSION['shell'] = md5($fetch['username'].$fetch['password']);
$_SESSION['ontime'] = time();
//echo $_SESSION['id']."<br>";
//echo $_SESSION['shell'];
$action = new action();
$action ->get_show_msg('admin/admin_main.php', $show = '操作已成功!');
}
}else
echo "<script language=javascript>alert('驗證碼錯誤');</script>";
?>
<!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=GB2312">
<title>用戶登錄</title>
<link href="style/global.css" rel="stylesheet" type="text/css">
<link href="style/link.css" rel="stylesheet" type="text/css">
<link href="style/layoutid.css" rel="stylesheet" type="text/css">
<script language="javascript">
function chform (obj) {
if (obj.username.value == "") {
alert("請輸入用戶名!");
obj.username.focus();
return false;
}
if (obj.password.value == "") {
alert("請輸入密碼!");
obj.password.focus();
return false;
}
if (obj.sccode.value == "") {
alert("請輸入驗證碼!");
obj.sccode.focus();
return false;
}
return true;
}
function RefreshImage(id)
{
document.getElementById(id).src ='Confirm.php?'+Math.random(1);
}
</script>
</head><body>
<!--用戶登錄開始-->
<div class="login">
<form id="form1" name="form1" method="post" action="" onsubmit="return chform(this)">
<ul>
<li class="loginbtbj fright" style="background-image: url("images/hydl.gif");"><a title="" href="javascript:%20close();"><img src="images/close.gif" alt="關閉" align="right" border="0" height="18" width="18"></a></li>
<li class="fyellowxx fcenter">
.............................................................................................................
</li>
<li class="padleft43">
用戶名:<input name="username" size="15" style="width: 150px;" type="text">
</li>
<li class="padleft43">
密碼:<input name="password" size="15" style="width: 150px;" type="password">
</li>
<li class="padleft43">
驗證碼:<input name="sccode" size="6" style="width: 50px;" type="text"><img id="re_confirm" onclick="RefreshImage('re_confirm')" src="Confirm.php">
<a title="看不清?" href="#" onclick="RefreshImage('re_confirm')">看不清?</a> <a href=register.php >注冊</a>
</li>
<li class="fyellowxx fcenter">
.............................................................................................................
<br>
<input name="Submit" src="images/dl.gif" style="border: 0pt none; width: 80px; height: 31px;" type="image">
</li>
</ul>
</form>
</div>
<!--用戶登錄結束-->
</body></html>
這個是驗證碼的程序 confirm.php 圖片什麼的代碼我就不穿了 LZ可以借鑒下 有一點需要注意 就是這個confirm文件裡面不能報錯 我在這卡了很久
因為header這個之前不能輸出文本 所以如果報錯 就會無法顯示驗證碼
<?php
session_start();
$random='';
for($i=1;$i<5;$i++){
$random .= dechex(rand(1,15));}
$_SESSION['rand']=$random;
$im = imagecreatetruecolor(40,20);
$bg = imagecolorallocate($im,0,0,0);
$te = imagecolorallocate($im,255,255,255);
imagestring($im,rand(1,6),rand(1,6),rand(1,6),$random,$te);
header("Content-type: image/jpeg");
imagejpeg($im);
?>
⑸ php中如何將string類型轉換為date類型插入到資料庫中的date類型欄位中,incorrect date value啥意思
1、首先介紹一下將String類型轉為Date類型的方法。需要導入java.text.SimpleDateFormat類。下面舉一個例子,比如有一個字元串 「2018-08-24「,想要轉為Date類型,代碼如圖所示。
⑹ actionscript3.0中new Date().time/1000 用php怎麼寫
在php中就是time()
在js或as中newDate().getTime()獲取的是毫秒為單位的時間( 和as 中的time屬性一樣 ),除以1000得到的就是秒為單位的時間
ActionScript Date
php中time()就是獲取以秒為單位的時間
兩者都是從1970.1.1起算,所以一樣
php中date() 是獲取格式化的日期,並不是一個數字,有一個必傳參數就是日期格式, 一般傳 'Y-m-d H:i:s' 這樣的,得出來是一個日期
⑺ 求教一個php輸出mysql日期格式問題
$datetime = strtotime($sqldate);
$newdate = date("y-m-d g:i A", $datetime);
$sqldate是你從sql里去的值。
望採納。
⑻ 如何使用php實現時間時時更新
JS啊...
下面的代碼放到你需要顯示的位置就OK了...
<span id="showDate"></span>
<script>
function getCurrTime(){
var date=new Date();
var weekArray=new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六");
var str=date.getFullYear()+"-"+date.getMonth()+"-"+date.getDate()+" "+date.getHours()+":"+date.getMinutes()+":"+date.getSeconds()+" "+weekArray[date.getDay()];
document.getElementById("showDate").innerHTML=str;
}
setInterval("getCurrTime()",1000);
</script>