(菜鸟飞飞) 页面内点击按钮,出现当前系统的时间戳 应该是用js实现的吧。可是对js一窍不通。谢谢回答了!!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <input type="text" id="t"><input type="button" onclick="getT()" value="当前系统时间戳(JavaScript形式)"><script language="javascript">function getT(){document.getElementById("t").value = Date.parse(new Date());}</script> 谢谢楼上的回答。但我不想要那个 text 表单。只需要把得到的时间戳赋给 php的 session就行。 本地的还是服务器的时间戳?这需要用到ajax(ajax效果最好) <?php$action = $_SERVER['SCRIPT_NAME'];if(isset($_POST['time'])){ $time = intval($_POST['time']) == 2? time: intval($_POST['time']); $_SESSION['time'] = $time;}?><input type="button" onclick="t(1)" value="本地时间戳"><input type="button" onclick="t(2)" value="服务器时间戳"><script src="jquery.js"></script><script>function t(t){ if(t == 1)time = Date.parse(new Date()); else time = t; $.post("<?php echo $action; ?>", {"time": time}, function(data){ if(t == 1)alert("本地时间保存成功!"); else alert("服务端时间保存成功!"); });}</script>注意我用了jquery,这样减少很多代码,上面的代码放到php页面中,当然了,也可将代码拆分成html和php的 上面有块小错误:$time = intval($_POST['time']) == 2? time(): intval($_POST['time']); 单纯的服务端时间保存<?php$action = $_SERVER['SCRIPT_NAME'];if(isset($_POST['time'])){ $_SESSION['time'] = time();}?><input type="button" onclick="t()" value="保存时间戳"><script src="jquery.js"></script><script>function t(){ $.post("<?php echo $action; ?>", {"set": 1}, function(data){ alert("时间保存成功!"); });}</script> 单纯的服务端时间保存这段代码放到程序里点击按钮没有反应呀。问个问题哈。我可以将第一楼的那个时间戳从text里拿出来么??我觉得第一楼最简单哈 我想问下为啥为这样写:<form name="form3" method="get" action=""> <input type="text" name="currenttime" id="t"><input type="button" onclick="getT()" value="当前系统时间戳(JavaScript形式)"><script language="javascript">function getT(){document.getElementById("t").value = Date.parse(new Date());}</script></form><?php$currenttime=$_GET["t"];echo $currenttime;?>currnettime却没有值呢???? Ajax 触发程序写Session 就可以了。时间用time() 函数就行了,因为是服务器时间。。欢迎访问 allniu.com 不错的PHP的网站,获取对你有所帮助 当然没有了,因为$_GET是需要请求的,我帮你改下:<?phpif(isset($_GET['submit']))echo time();?><form method="get"><input type="submit" name="submit" value="时间"></form> kyzy_yy_pm, 非常感谢您一直回答我,问题解决了。以后还会有更多小白问题麻烦您哈!!! apache服务不能启动,在线等待 【待解决】有没谁知道算命的原理,想做一个算命程序 PHP, 能否打开其他网站的Access? 请教如何用php编写mysql的数据库备份程序? php文件里面怎么填加HTML 怎样实现form 中的一个文本框的值随一个下拉框中的值而变化? 急问:在51.net的php空间,下载文件为何无法使用中文“别名” 都谁是在用虚拟主机的?哪家能好点? 我有个建议 register new php version无法点击的问题 不会的php面试题! 关于php读取xml
<script language="javascript">
function getT(){document.getElementById("t").value = Date.parse(new Date());}
</script>
<?php
$action = $_SERVER['SCRIPT_NAME'];
if(isset($_POST['time'])){
$time = intval($_POST['time']) == 2? time: intval($_POST['time']);
$_SESSION['time'] = $time;
}
?>
<input type="button" onclick="t(1)" value="本地时间戳">
<input type="button" onclick="t(2)" value="服务器时间戳">
<script src="jquery.js"></script>
<script>
function t(t){
if(t == 1)time = Date.parse(new Date());
else time = t;
$.post("<?php echo $action; ?>", {"time": time}, function(data){
if(t == 1)alert("本地时间保存成功!");
else alert("服务端时间保存成功!");
});
}
</script>注意我用了jquery,这样减少很多代码,上面的代码放到php页面中,当然了,也可将代码拆分成html和php的
$action = $_SERVER['SCRIPT_NAME'];
if(isset($_POST['time'])){
$_SESSION['time'] = time();
}
?>
<input type="button" onclick="t()" value="保存时间戳">
<script src="jquery.js"></script>
<script>
function t(){
$.post("<?php echo $action; ?>", {"set": 1}, function(data){
alert("时间保存成功!");
});
}
</script>
<input type="text" name="currenttime" id="t"><input type="button" onclick="getT()" value="当前系统时间戳(JavaScript形式)">
<script language="javascript">
function getT(){document.getElementById("t").value = Date.parse(new Date());}
</script>
</form>
<?php
$currenttime=$_GET["t"];
echo $currenttime;?>currnettime却没有值呢????
<?php
if(isset($_GET['submit']))echo time();
?>
<form method="get">
<input type="submit" name="submit" value="时间">
</form>