Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Nov 2006
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to add date and time this code

    <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

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,918
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    Does this help?

    <SCRIPT Language="JavaScript">
    <!--
    var months=new Array("","JANUARY","FEBRUARY","MARCH","APRIL","MAY","JUNE","JULY","AUGUST",
    "SEPTEMBER","OCTOBER","NOVEMBER","DECEMBER");
    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);
    // -->
    </SCRIPT>

  • #3
    New Coder
    Join Date
    Nov 2006
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,918
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    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?

  • #5
    New Coder
    Join Date
    Nov 2006
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts
    my english is poor sorry

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

  • #6
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,918
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    Have a look at these:-

    http://www.js-examples.com/page/java...le.html?ex=338

    http://www.javascriptkit.com/script/...calendar.shtml

    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.

  • #7
    New Coder
    Join Date
    Nov 2006
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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 ;



  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •