PDA

View Full Version : How to add date and time this code



winpeace
11-10-2006, 07:01 PM
<td width="30%" valign="top"><b>Name:</b></td>
<script language="javascript" src="/templates/js.tpl"></script>

I want to add date and time near name


which code I add;
js.tpl(script) and top the td code.Please help

jscheuer1
11-10-2006, 10:14 PM
<td width="30%" valign="top"><b>Name:</b><br>Date/Time: <script type="text/javascript">
document.write(new Date().toLocaleString());
</script></td>

winpeace
11-11-2006, 07:03 AM
hi,
thank you for messaj .the code is true.but I use in comment form.So the time is stop when comment send the users.But this code passing in comments

jscheuer1
11-11-2006, 07:30 AM
I'm still a little vague on what you are after but, this works in a different sort of way and may provide a useful enough example for your purposes:


<span>Name<br>Date/Time: <span id="dt"><script type="text/javascript">
document.write(new Date().toLocaleString());
</script></span><script type="text/javascript">
setInterval("document.getElementById('dt').innerHTML=new Date().toLocaleString()", 1000);
</script></span>

It really boils down to: When do you want to capture the current date and time and where do you want that data sent?

winpeace
11-11-2006, 12:42 PM
sorry I don't want this code.Because the time is continuous refresh with this code.But I want the time is stop when comment is send like this ;

http://img295.imageshack.us/img295/3772/untitled1zi6.jpg

jscheuer1
11-11-2006, 07:44 PM
Then stop it or generate it to begin with at that point. I cannot be more specific without the code used to generate the comment in the first place. However, it looks like a server side package. So, it probably has a way to include the date/time stamp in the comment already. Read your documentation or post a question in a forum dedicated to that package.