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

11-10-2006, 07:57 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

Philip M
11-10-2006, 09:30 PM
Does this help?

<SCRIPT Language="JavaScript">
var months=new Array("","JANUARY","FEBRUARY","MARCH","APRIL","MAY","JUNE","JULY","AUGUST",
var time=new Date();
var amonth=months[time.getMonth() + 1];
var date=time.getDate();
var year=time.getYear();
var hh = time.getHours();
var mn = time.getMinutes();
if (year < 2000) {year = 1900 + year}
var ending = "TH";
if (date == 1 || date == 21 || date == 31) ending = "ST";
if (date == 2 || date == 22) ending = "ND";
if (date == 3 || date == 23) ending = "RD";
document.write(" " + date + ending + " " + amonth + " " + year + " " + hh +":" + mn);
// -->

11-11-2006, 08:27 AM
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

Philip M
11-11-2006, 08:37 AM
I am sorry, winpeace, but I am having problems understanding you. English is obviously not your first langauge.

Are you saying that you have a form containing comments which the user fills in, the form is then sent to you, but you want the date and time it was sent to be automatically included in the message?

11-11-2006, 08:52 AM
my english is poor sorry :)

I want when the comment posting,the time is stop.I want to capture the current date and time

Philip M
11-11-2006, 09:40 AM
Have a look at these:-



I am still not sure exactly what you are looking for. Remember that JavaScript can be disabled by the user, so if the date and time are important it would be best to do this server-side.

11-11-2006, 01:44 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 ;