473,396 Members | 1,917 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Time Function returns Wrong Time

I am writing an ASP program that includes a Form.

When the Form is submitted I use the Date() and Time() functions to put the
date and time into the Body part of the e-mail.
The time reported is three hours earlier than the time at which the Form is
actually submitted.

I understand these functions are evaluated on the server so the server must
be in a time zone three hours earlier than where I am .

Is there any way I can get the local time at the location where the user is
actually located. ??

Thanks
Oct 15 '05 #1
5 6403
RICHARD BROMBERG wrote on 15 okt 2005 in
microsoft.public.inetserver.asp.general:
I am writing an ASP program that includes a Form.
The ASP of the form submitting page is unimportant for your Q.

The page the form is submitted to should be an .asp page.
When the Form is submitted I use the Date() and Time() functions
Are you sure this is serverside ASP?

ASP vbscript now() contains both date and time.
to
put the date and time into the Body part of the e-mail.
The time reported is three hours earlier than the time at which the
Form is actually submitted.

I understand these functions are evaluated on the server
All ASP code is executed on the server.
However Date() and Time() could also be clientside VBS on a IE browser.
so the server
must be in a time zone three hours earlier than where I am .

Is there any way I can get the local time at the location where the
user is actually located. ??


If you mean by "ASP program" "ASP vbscript":

myDateTime = DateAdd("h", 3, Now)

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Oct 15 '05 #2
To the OP, you'll have to forgive Captain A-hole's purposeful lack of
anything usable in his reply. It's a little game of his, he likes to be as
diminutive as possible without compromising the overtly disingenuous nature
of the non-information he 'shares.'

As for a solution, the most straight-forward way is to create a [JavaScript]
Date object on the client, call it's getTimezoneOffset() method, and post
the result to the server in a hidden input, optionally keeping it as part
of the user's profile data.

Sadly it's sometimes the case that the user has the time-of-day set for
his/her geographic area, but has the wrong timezone configured. Further, as
a matter of logistics more than anything, you can expect the time-of-day
(UTC) according to any given machine, to vary slightly from your server.

So if accuracy is of extreme importance, you should post both the timezone
offset and the time-of-day (UTC) from the client to yourself, convert your
server time to UTC, and see if they match, +-15 minutes or so. If not,
inform the user that there is a configuration issue.

Given that you can trust the timezone offset, acquire it from the client via
script, and use it to calculate the transaction time-of-day stamp from
server time. Better yet, always store server-based time-of-day stamp as
UTC, and adjust it to local time when you render the page.

Resist the temptation to simply acquire and store the local time-of-day from
the client. People have been known to forge time-of-day stamps by adjusting
their system time. Server time is more reliable; storing it as UTC gives
you an always-known frame of reference, and avoids inaccuracy caused by
multiple conversions.

So to correct myself, the most straight-forward way is to use your server's
time, stored as UTC, and render it as local time when you render the page,
based on timezone offset.
-Mark
(btw, "Evertjan", I'll top-post any time I damn well please, if you have an
issue, keep it to yourself. See other comments injected into post below...)

"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn********************@194.109.133.242...
RICHARD BROMBERG wrote on 15 okt 2005 in
microsoft.public.inetserver.asp.general:
I am writing an ASP program that includes a Form.
The ASP of the form submitting page is unimportant for your Q.


Well now that's not entirely true, is it? Will he not construct that form,
as well as any event script, in ASP?

The page the form is submitted to should be an .asp page.
Painfully obvious, content == 0.

When the Form is submitted I use the Date() and Time() functions


Are you sure this is serverside ASP?


Yes he's sure, you dimwit, the functions Date() and Time() are both
supported by VBS -- condescending and stupid is a really poor combination.

ASP vbscript now() contains both date and time.
to
put the date and time into the Body part of the e-mail.
The time reported is three hours earlier than the time at which the
Form is actually submitted.

I understand these functions are evaluated on the server
All ASP code is executed on the server.


No kidding? Wow, I wonder if the OP was making reference to this with his
statement, "I understand these functions are evaluated on the server". Bah,
no, couldn't possibly, thank the heavens we have "Evertjan" to set us
straight on these complex topics.

However Date() and Time() could also be clientside VBS on a IE browser.
so the server
must be in a time zone three hours earlier than where I am .

Is there any way I can get the local time at the location where the
user is actually located. ??
If you mean by "ASP program" "ASP vbscript":


"Program" is a substantially correct term -- was there a point you were
trying to make? A relevant point? Something that might enhance the
discussion and leave the OP better-informed? If so, I can't imagine what it
would be, other than perhaps your asserting your god-given right to waste a
few dozen bytes of bandwidth... again.

myDateTime = DateAdd("h", 3, Now)
Hey now! There's an inspired solution, hard-code a 3 hour offset on the
server side -- are you available to, like, write "ASP vbscript" um...
programs or something? What's your rate? That's the kind of dynamic you
just can't find everywhere, ya know? How lucky we are that you so
generously shared your methodology with us.

Oh btw, what happens if people from more than just one timezone use the
site? Hmm, your solution doesn't seem to consider that in the slightest...
Oh gosh, that makes it sort of... useless, doesn't it? I guess I'm left
shocked and amazed...

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Oct 16 '05 #3
Here's how I like to handle time zones:

Classic ASP Design Tips - Time Zones
http://www.bullschmidt.com/devtip-timezones.asp

Best regards,
J. Paul Schmidt, Freelance Web and Database Developer
http://www.Bullschmidt.com
Access Database Sample, Web Database Sample, ASP Design Tips

*** Sent via Developersdex http://www.developersdex.com ***
Oct 17 '05 #4

"Mark J. McGinty" <mm******@spamfromyou.com> wrote in message
news:u$**************@TK2MSFTNGP09.phx.gbl...

Oops, this:
So if accuracy is of extreme importance, you should post both the timezone
offset and the time-of-day (UTC) from the client to yourself, convert your
server time to UTC, and see if they match, +-15 minutes or so. If not,
inform the user that there is a configuration issue.


should of course read:

.... post both the timezone offset and the *local* time-of-day from the
client to yourself, use them to calc UTC, convert your server time to UTC...

Sorry about that,
Mark
Oct 17 '05 #5
Many thanks to almost one and all.

The response from Evertjan in the Netherlands was useless, Just a small
pothole in the internet superhighway.
"Bullschmidt" <no****@devdex.com> wrote in message
news:O%****************@TK2MSFTNGP10.phx.gbl...
Here's how I like to handle time zones:

Classic ASP Design Tips - Time Zones
http://www.bullschmidt.com/devtip-timezones.asp

Best regards,
J. Paul Schmidt, Freelance Web and Database Developer
http://www.Bullschmidt.com
Access Database Sample, Web Database Sample, ASP Design Tips

*** Sent via Developersdex http://www.developersdex.com ***

Oct 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: androtech | last post by:
Hello, I'm looking for a function that returns a date range for a specified week number of the year. I'm not able to find functions like this anywhere. Any pointers/help would be much...
3
by: Gizmo | last post by:
hello all have been trying to write a Mid() function a bit like the one in vb. i come to compile it and there are no errors however when i run it an error accours and it says the program has to...
2
by: Terry | last post by:
I have used the code provided in the PreciseDateDiff function at the following Access Web link to calculate the time change date (from Daylight to Standard time and vice versa): ...
17
by: MLH | last post by:
A97 Topic: If there is a way to preserve the values assigned to global variables when an untrapped runtime error occurs? I don't think there is, but I thought I'd ask. During development, I'm...
2
by: lucifer | last post by:
actually i am transmitting data over wireless medium so i have to control the data ie slow it down thats i have to get a delay in the transmitting function inversely to the speed of the the...
9
by: Christian Christmann | last post by:
Hi, I was just going through this exercise http://www.cas.mcmaster.ca/~franek/books/membook-answers/ch4/answers-ch4-3.html and I'am confused about the answer. It says: "... the compiler...
12
by: pekka | last post by:
I'm trying to measure user input time with my Timer class object. It isn't as easy as I expected. When using std::cin between timer start and stop, I get zero elapsed time. For some unknown reason,...
9
by: Ron Adam | last post by:
I'm having some cross platform issues with timing loops. It seems time.time is better for some computers/platforms and time.clock others, but it's not always clear which, so I came up with the...
0
yasirmturk
by: yasirmturk | last post by:
Standard Date and Time Functions The essential date and time functions that every SQL Server database should have to ensure that you can easily manipulate dates and times without the need for any...
15
by: student4lifer | last post by:
Hello, I have 2 time fields dynamically generated in format "m/d/y H:m". Could someone show me a good function to calculate the time interval difference in minutes? I played with strtotime() but...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.