<input type="text" name="postdb[times]" size="20" onblur="if(value==""){nowtime();}" id="times" > function nowtime(){ var now= new Date(); var year=now.getYear(); var month=now.getMonth()+1; var day=now.getDate(); var hour=now.getHours(); var minute=now.getMinutes(); var second=now.getSeconds(); var nowtimes=year+"-"+month+"-"+day+" "+hour+":"+":"+minute+":"+second; document.getElementById("times").value=nowtimes; }
---------------------------------
过程化风格<?php
$date = date_create('2000-01-01', timezone_open('Pacific/Nauru'));
echo date_format($date, 'Y-m-d H:i:sP') . "\n";date_timezone_set($date, timezone_open('Pacific/Chatham'));
echo date_format($date, 'Y-m-d H:i:sP') . "\n";
?>
<input type="text" name="postdb[times]" size="20" onblur="if(value==""){nowtime();}" id="times" >
function nowtime(){
var now= new Date();
var year=now.getYear();
var month=now.getMonth()+1;
var day=now.getDate();
var hour=now.getHours();
var minute=now.getMinutes();
var second=now.getSeconds();
var nowtimes=year+"-"+month+"-"+day+" "+hour+":"+":"+minute+":"+second;
document.getElementById("times").value=nowtimes;
}
<input type="text" name="postdb[times]" size="15" value="2011-04-18 11:49:14">怎么不行呢?
楼主用的是全角的引号,你这是copy #1的回复,当然没问题啦,老大也有看走眼的时候,哈哈
时间:
<input type="text" name="postdb[times]" size="20" value="<?php date_default_timezone_set('Asia/Shanghai'); echo date("Y-m-d H:i:s");?>"
id="times" > 不行,、、、输出显示是<?php date_default_timezone_set('Asia/Shanghai'); echo date(
我按你代码直接复制过去的