Adjusting time from server time to local time

This is a discussion on "Adjusting time from server time to local time" within the Classic ASP section. This forum, and the thread "Adjusting time from server time to local time are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > Classic ASP

Notices


Closed Thread
 
LinkBack Thread Tools
  #1 (permalink)  
Old Jun 14th, 2004, 07:41
Tim356's Avatar
Reputable Member
Join Date: Nov 2003
Location: Australia
Age: 25
Posts: 331
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Tim356
Adjusting time from server time to local time

I've been using
Code: Select all
FormatDateTime(Now,3)
to display the time of post in the blog I'm creating, but of course that's server time.

How can I adjust the display time?

  #2 (permalink)  
Old Jun 14th, 2004, 08:31
Highly Reputable Member
Join Date: Aug 2003
Location: Australia
Posts: 662
Thanks: 0
Thanked 0 Times in 0 Posts
I guess you could always subtract (or add may depending on the case...) your time with the server time. Then display that.
  #3 (permalink)  
Old Jun 14th, 2004, 08:39
Most Reputable Member
Join Date: Jul 2003
Posts: 1,856
Thanks: 0
Thanked 0 Times in 0 Posts
You mean, you want it to display relative to the time on the client side?

The only way I can think of doing that is with a Javascript, which is fed your time zone and works out the time on the client machine.
  #4 (permalink)  
Old Jun 14th, 2004, 08:45
Highly Reputable Member
Join Date: Jul 2003
Location: Ipswich, UK
Posts: 690
Thanks: 0
Thanked 0 Times in 0 Posts
I think Court Jester has a point, if you know the time difference between you and the server, just subtract the appropriate amount of hours...

If England hadnt lost last night and I hadnt got so drunk, i wouldnt be feeling so ill today and i might have written the code to do this but, in my current state, i cant!
  #5 (permalink)  
Old Jun 14th, 2004, 13:49
Tim356's Avatar
Reputable Member
Join Date: Nov 2003
Location: Australia
Age: 25
Posts: 331
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Tim356
I've tried adding the appropriate amount of hours (17 to be exact), but I keep having problems. I can get it to do it, but then the date is still yesterday... and then I have the problem of converting it to 12 hour clock:
Code: Select all
if xtime > 12 then
xtime = (xtime)-12
end if
(something similar to that)
but when the server time is 10am, add 17 hours, becomes 27:00, minus 12 hours, 15:00... no no no... I gues I could add more if statements there (if xtime > 20 then...). I'll give that a go tomorrow. It's 12am here almost, so I'm going to bed, I was up til 2am last night doing this...

My brain is too messed up, need sleep.
  #6 (permalink)  
Old Jun 14th, 2004, 14:00
Highly Reputable Member
Join Date: Jul 2003
Location: Ipswich, UK
Posts: 690
Thanks: 0
Thanked 0 Times in 0 Posts
Code: Select all
NewDate = DateAdd("h", 17, Now)

  #7 (permalink)  
Old Jun 15th, 2004, 01:01
Tim356's Avatar
Reputable Member
Join Date: Nov 2003
Location: Australia
Age: 25
Posts: 331
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Tim356
This will add 17 hours to the server time? Excellent, champion...

Thanks!
  #8 (permalink)  
Old Jun 20th, 2004, 20:43
Rob's Avatar
Rob Rob is offline
Head Admin & CEO

SuperMember
Join Date: Jul 2003
Location: at my desk
Age: 34
Posts: 2,951
Blog Entries: 7
Thanks: 7
Thanked 3 Times in 3 Posts
Send a message via MSN to Rob Send a message via Skype™ to Rob
lol smokie.

your one-liners crack me up.

However Smokie, as a great teacher of coding practice, I'm sure you meant:-
Code: Select all
NewDate = DateAdd("h", 17, Now())
__________________
Rob - SEO Specialist
Owner & Founder of Webforumz.com

I am currently unavailable for private work
  #9 (permalink)  
Old Jun 21st, 2004, 04:22
Highly Reputable Member
Join Date: Aug 2003
Location: Australia
Posts: 662
Thanks: 0
Thanked 0 Times in 0 Posts
THAT A BOY ROB!!!! LOL
  #10 (permalink)  
Old Jun 21st, 2004, 08:13
Highly Reputable Member
Join Date: Jul 2003
Location: Ipswich, UK
Posts: 690
Thanks: 0
Thanked 0 Times in 0 Posts
blame Microsoft...
  #11 (permalink)  
Old Jun 21st, 2004, 14:57
Tim356's Avatar
Reputable Member
Join Date: Nov 2003
Location: Australia
Age: 25
Posts: 331
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Tim356
Thanks Rob!
Closed Thread

Tags
adjusting, time, server, local

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 On

Similar Threads
Thread Thread Starter Forum Replies Last Post
My first time jabo Introduce Yourself 3 Feb 26th, 2008 17:33
sorry, need more help with time saltedm8 PHP Forum 12 Oct 6th, 2007 21:04
Ok you get this all the time... Docherty Web Page Design 6 Nov 19th, 2005 14:55
Server time and date script gribble JavaScript Forum 1 Aug 16th, 2005 09:53
What's the time? Rob JavaScript Forum 2 Sep 25th, 2003 18:01


All times are GMT. The time now is 20:45.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43