Current Date/Time RRS feed

  • Question

  • User-110847984 posted


    I'm trying to assign the current date to the hidden field SndDate and the current time to the hidden field SndTime.
    Here is the code I’m using in the two files.

    File Tform.htm contains the following code:

    <meta http-equiv="Content-Language" content="pt">
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
     <form method="POST" action="tsend.asp" onsubmit="return FrontPage_Form1_Validator(this)" language="JavaScript" name="FrontPage_Form1">
      &nbsp;<!--webbot bot="Validation" s-data-type="Integer" s-number-separators="x" --><input type="text" name="ClienteID" size="20"></p>
      <p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
      <input type="hidden" name="SndDate" value="">
      <input type="hidden" name="SndTime" value="">

    File Tsend.asp contains the following code:

    dim Mail
    Set Mail = Server.CreateObject("Persits.MailSender")


    Mail.Host = "localhost"
    Mail.From = "Sender_Address@somesite.com"
    Mail.FromName = "WebSite Form"
    Mail.AddAddress "Destination_Address@somesite.com"
    Mail.Subject = "Form Results"
    Mail.IsHTML = True
    Mail.Body = "<HTML><BODY><LEFT>"+"Cliente ID: "+Request("ClienteID")+"<P>User: "+LcUser+"<P>Address: "+LcAddr+"<P>User Agent: "+LcAgen+"<P>"+"Date: "+Request("SndDate")+"<P>"+"Time: "+Request("SndTime")+"<P></LEFT></BODY></HTML>"

    On Error Resume Next

    If Err <> 0 Then
    Response.Write "An error occurred: " & Err.Description
    end if


    <div align="center">

    Can anyone help?

    Thursday, March 15, 2018 1:16 AM

All replies

  • User-460007017 posted

    Hi CNTLM,

    I think it is not difficult to get current date value and you only need to use document.getElementById().value to grant the current date to your SndTime hidden input control.


    Best Regards,

    Yuk Ding

    Thursday, March 15, 2018 9:29 AM
  • User906018781 posted

    Put something like this just before the closing </body> tag in TForm.htm.  It presumes .toLocaleString() is "dd/mm/yyyy, hh:mm:ss AM/PM".  Depending on your location and user population, you may need a more robust solution.

       var d = (new Date()).toLocaleString().split(',');
       document.getElementsByName('SndDate')[0].value = d[0];
       document.getElementsByName('SndTime')[0].value = d[1].Trim();

    It's unclear to my why you'd send this as it should be the same as getting Now() on the server unless you're looking for TZ information by doing so.  Particularly, as it will show the time the form was rendered, not when the submit occurred.

    Thursday, March 22, 2018 9:21 PM
  • User-110847984 posted


    I tried that sugestion, but it did not work.

    Meanwhile someone else in another forum give me a suggestion that worked and I’m using it.
    Thanks, any way for trying to help.

    Tuesday, April 10, 2018 11:47 AM