Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Date()

Reply
Thread Tools

Date()

 
 
Keith
Guest
Posts: n/a
 
      04-23-2004
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


 
Reply With Quote
 
 
 
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      04-23-2004
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.


 
Reply With Quote
 
 
 
 
Curt_C [MVP]
Guest
Posts: n/a
 
      04-23-2004
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:(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
Dave Anderson
Guest
Posts: n/a
 
      04-23-2004
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.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments