Solved

Time Zone Diff in ASP

Posted on 2001-08-03
6
237 Views
Last Modified: 2012-05-04
My server is in Atlanta, I am in Seattle.

What is the asp code for displaying the time difference? I am close but after midnight my time is off for a few hours until Seattle catches up ha ha!

Thanks everyone,
Jim S.
0
Comment
Question by:TenTonJim
6 Comments
 
LVL 5

Expert Comment

by:nilapenn
Comment Utility
use datediff function

response.write datediff("h",atlantadate,seattledate)
0
 
LVL 2

Author Comment

by:TenTonJim
Comment Utility
how do I get the 2 in the code to compare?

sorry don't mean to be ignorant...

Thanks,
Jim S.
0
 
LVL 9

Accepted Solution

by:
msdixon earned 50 total points
Comment Utility
actually, you don't want to use datediff. that would show you the difference. use datadd:
DateAdd(interval, number, date)
see:
http://msdn.microsoft.com/scripting/default.htm?/scripting/vbscript/doc/vsfctDateAdd.htm

response.write dateadd("h", -3, now())
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 5

Expert Comment

by:dgorin
Comment Utility
Here is client-side code to determine the difference between the browser time and GMT to get you started (if I recall correctly it's snipped from the MS documentation).  You can put the browser time in a hidden form field and when you submit the page you can compare to the server time using the server VBScript myTime=Now()

You can put the server time in your browser page and do all the comparison client-side if you wish.

function timezone() {

   var d, tz, s = "The current local time is ";
   d = new Date();
   tz = d.getTimezoneOffset();
   if (tz < 0)
      s += tz / 60 + " hours before GMT";
   else if (tz == 0)
      s += "GMT";
   else
      s += tz / 60 + " hours after GMT";
   return(s);
}
0
 
LVL 2

Author Comment

by:TenTonJim
Comment Utility
ok let me look as the midnight hour approaches and see what happens...

so far msdixon is going to get the nod, this looks to be exactly what I wants

Thanks,
Jim S.
0
 
LVL 2

Author Comment

by:TenTonJim
Comment Utility
Thank you very much!

Exact answer... very nice answer... 1 line of code that's a bonus!!

Thank you to the other folks that gave answers also. msdixon got the nod because all I had to do was plug it in and it worked right off the bat.


Thanks,
Jim S.

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
db results not fully dispplayed 17 38
Want the count number from this QUery 2 26
Select distinct 25 60
Summernote required 3 56
I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now