Dedecms的发布时间因为经常要把以前的时间更新到现在的时间,手动输入真的太麻烦了,所以决定把这一小功能在后台实现,共有两种方式。
以上两种方式都有一个弊端,因为采用PHP获取时间,获取到的时间只是打开文档那一刻的时间
举例:例如你的文档原发布时间为2009年8月6日11点30分22秒,你编辑文档的时间为2010年4月30日8点30分22秒(编辑时间即为当前时间),如果你编辑文章的时间较长,使用了5分钟,PHP获取的时间不会延时5分钟,而是使用前面提到的编辑时间,稍候我会找出完美的方法。
打开dede/templets/article_edit.htm(dede是后台路径,软件和其他模型的模板,照葫芦画瓢,不再赘述),查找以下代码:
<?php $nowtime = GetDateTimeMk($arcRow["pubdate"]); echo "<input name=\"pubdate\" value=\"$nowtime\" type=\"text\" id=\"pubdate\" style=\"width:200\">"; ?>
修改为:
<?php $nowtime = GetDateTimeMk($arcRow["pubdate"]); $uptime = date("Y-m-d G:i:s"); echo "<input name=\"pubdate\" value=\"$nowtime\" type=\"text\" id=\"pubdate\" style=\"width:160\"> <input type=\"button\" value=\"更新?\" onclick=\"liehuo_time()\">\n"; echo "<script type=\"text/javascript\">\n"; echo "function liehuo_time(){\n"; echo "form1.pubdate.value=\"$uptime\";\n"; echo "}\n"; echo "</script>\n"; ?>
打开dede/templets/article_edit.htm(dede是后台路径,软件和其他模型的模板,照葫芦画瓢,不再赘述),查找以下代码:
<?php $nowtime = GetDateTimeMk($arcRow["pubdate"]); echo "<input name=\"pubdate\" value=\"$nowtime\" type=\"text\" id=\"pubdate\" style=\"width:200\">"; ?>
修改为:
<?php $nowtime = date("Y-m-d G:i:s"); echo "<input name=\"pubdate\" value=\"$nowtime\" type=\"text\" id=\"pubdate\" style=\"width:200\">"; ?>