Date()

Discussion in 'ASP General' started by Keith, Apr 23, 2004.

  1. Keith

    Keith Guest

    If I use <%Date()%> <%Time()%> to insert the current date and time into
    hidden fields on my page which I then insert into a database via a web form,
    how accurate are the dates?

    Are these (as I suspect) the data and time of the local/remote machine at
    the time the page was loaded?

    I am trying to find out if this is the case, because if a user opens the
    form and keeps it open for 10 minutes before submitting it, then the date
    and time recorded this way will be 10 minutes old at the time of submission.

    Is this correct?

    And if so, is there a way around it where the date and time can be inserted
    into hidden fields at the time of submit?

    Thanks
    Keith, Apr 23, 2004
    #1
    1. Advertising

  2. Keith wrote:
    > If I use <%Date()%> <%Time()%> to insert the current date and time
    > into hidden fields on my page which I then insert into a database via
    > a web form, how accurate are the dates?


    Depends on how you define "accurate"

    >
    > Are these (as I suspect) the data and time of the local/remote
    > machine at the time the page was loaded?


    Yes

    >
    > I am trying to find out if this is the case, because if a user opens
    > the form and keeps it open for 10 minutes before submitting it, then
    > the date and time recorded this way will be 10 minutes old at the
    > time of submission.
    >
    > Is this correct?


    Yes

    >
    > And if so, is there a way around it where the date and time can be
    > inserted into hidden fields at the time of submit?


    a - use client-side code to refresh the values in the form's onsubmit event
    (this is offtopic for this list - if you need help with this ask in one of
    the scripting or dhtml newsgroups

    b - stop using the hidden textboxes. Use code in the page to which the form
    is being submitted to calculate the current time and date.

    Bob Barrows

    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
    Bob Barrows [MVP], Apr 23, 2004
    #2
    1. Advertising

  3. Keith

    Curt_C [MVP] Guest

    hare your asp use the Date() and Time() when it's posted/saved, not when
    it's rendered to the screen.
    Also, those are Server based values, not client.

    --
    Curt Christianson
    Owner/Lead Developer, DF-Software
    Site: http://www.Darkfalz.com
    Blog: http://blog.Darkfalz.com


    "Keith" <@.> wrote in message news:...
    > If I use <%Date()%> <%Time()%> to insert the current date and time into
    > hidden fields on my page which I then insert into a database via a web

    form,
    > how accurate are the dates?
    >
    > Are these (as I suspect) the data and time of the local/remote machine at
    > the time the page was loaded?
    >
    > I am trying to find out if this is the case, because if a user opens the
    > form and keeps it open for 10 minutes before submitting it, then the date
    > and time recorded this way will be 10 minutes old at the time of

    submission.
    >
    > Is this correct?
    >
    > And if so, is there a way around it where the date and time can be

    inserted
    > into hidden fields at the time of submit?
    >
    > Thanks
    >
    >
    Curt_C [MVP], Apr 23, 2004
    #3
  4. Keith wrote:
    >
    > And if so, is there a way around it where the date and time can be
    > inserted into hidden fields at the time of submit?


    Why not just let the database determine the time when you insert? In SQL
    Server, for example, you can use GETDATE() as the default value for a
    DATETIME field.


    --
    Dave Anderson

    Unsolicited commercial email will be read at a cost of $500 per message. Use
    of this email address implies consent to these terms. Please do not contact
    me directly or ask me to contact you directly for assistance. If your
    question is worth asking, it's worth posting.
    Dave Anderson, Apr 23, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matt
    Replies:
    1
    Views:
    597
    Matthew Speed
    Nov 8, 2003
  2. Peter Grison

    Date, date date date....

    Peter Grison, May 28, 2004, in forum: Java
    Replies:
    10
    Views:
    3,250
    Michael Borgwardt
    May 30, 2004
  3. Matt
    Replies:
    2
    Views:
    515
    Pete Becker
    Nov 8, 2003
  4. Matt
    Replies:
    3
    Views:
    719
    Richard Heathfield
    Nov 8, 2003
  5. Matt
    Replies:
    11
    Views:
    405
    Aaron Bertrand [MVP]
    Nov 8, 2003
Loading...

Share This Page