Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Active Server Pages (ASP)
Expertise: Beginner
Jul 7, 1999

Accessing a Client's date&time Within ASP

Question:
I have an ASP that records a text of notes created by a user. I save this note in a database along with a date&time stamp. If the client is in a different time zone, the app picks up the date&time from my server. I want to pick up the current date/time in the client's time zone. How should I handle this?

Answer:

One way to access the client's date and time is to have it sent along with the other information in the form.

Ask the user to fill in the date and time, or get it using client side scripting.

If you need to use the scripting solution:

1. Have a hidden field in your form.

"dt"e

2. Define a function to run when the form is submitted.

3. Create a FillDateTime function using Client side Javascript.

4. In this function, use:

var dd = new date();
    document.info.dt.value = dd;
    return true;

This is necessary in order for the function to work properly.

5. In your Server Side ASP script, access the field "dt" to obtain the client side date and time. The date and time will have a format like this: Thu Jun 17 12:11:27 EDT 1999. Once this is set you can modify the format.

DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date