|
Close, but not quite. I am sure it is just typos but what is m supposed to be, month or minute? Also the month is displayed as three letters, not a two digit number. Also I agree with David, you should get the local timezone from the local machine, not from the user's profile. Just one less thing for the server to do.
[edit]
Also, not all time zones are full hours off of UTC. Newfoundland is -3.5.
[/edit]
[edit2]
Do not forget about daylight savings.
This is going to be more difficult then spending two minutes to slap together a small script. But keep working at it, it is avery good idea.
[/edit2]
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
the first "bug's" are solved
look here http://xwega.com/codeproject/timezone.asp[^]
PJ Arends wrote:
Also, not all time zones are full hours off of UTC. Newfoundland is -3.5.
i think this is done also , because now i'm usin the get getTimezoneOffset() that return the value in minutes and calculating the correct time using minutes instead of hours
PJ Arends wrote:
Do not forget about daylight savings
Any idea on how to calculate this?
|
|
|
|
|
I dont need to think of time zones or even daylight saving...
All i need is to get the date diff from server and client and apply that date diff to the date in question.
function ConvertTime(svrdate,anydate)<br />
{<br />
clientDate = new Date();<br />
serverDate = new Date(svrdate);<br />
date = new Date(anydate);<br />
<br />
datediff = (clientDate.valueOf()-serverDate.valueOf())/1000/60;
date.setMinutes(date.getMinutes()+datediff);
<br />
h = date.getHours();<br />
n = date.getMinutes();<br />
sTime = h+":"+((n<10)?"0"+n:n)+" ";<br />
sDate = new String(date.toUTCString());<br />
sDate = sDate.substr(5,6); <br />
sDate+=" '"+(String(date.getFullYear()).substr(2,2));<br />
sTime+=sDate;<br />
document.write(sTime);<br />
}<br />
<br />
<script>ConvertTime("<%=Now%>","03-25-2005 17:06")</script>
http://xwega.com/codeproject/timezone.asp[^]
|
|
|
|
|
Looks good, but make sure you test it with a bunch of different dates (ie over new years, leap years, etc) to make sure all the bugs are out. Then maybe email it directly to Chris and see if he wants to go through the effort of integrating it.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
Wow, looks very good. I appreciate the effort you put into this
Nish
|
|
|
|
|
thank you.
Very nice to ear it.
Any chance this end up on the CodeProject boards some day?
|
|
|
|
|
Max Santos wrote:
you can provide a way to configure time zone in the profile
That already exists, in fact Chris put that setting there just for the purpose you suggest. But since I see you're working on some script, I wanted to point out that the user's time zone is already available.
--Mike--
LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ
Strange things are afoot at the U+004B U+20DD
|
|
|
|
|
done !
i have reworked the script. thing is done, can you give it a try?.
I dont need to think of time zones or even daylight saving...
All i need is to get the date diff from server and client and apply that date diff to the date in question.
<br />
function ConvertTime(svrdate,anydate)<br />
{<br />
clientDate = new Date();<br />
serverDate = new Date(svrdate);<br />
date = new Date(anydate);<br />
<br />
datediff = (clientDate.valueOf()-serverDate.valueOf())/1000/60;
date.setMinutes(date.getMinutes()+datediff);
<br />
d = date.getDate();<br />
m = date.getMonth()+1;<br />
h = date.getHours();<br />
n = date.getMinutes();<br />
sTime = h+":"+((n<10)?"0"+n:n)+" ";<br />
sDate = new String(date.toUTCString());<br />
sDate = sDate.substr(5,6); <br />
sDate+=" '"+(String(date.getFullYear()).substr(2,2));<br />
sTime+=sDate;<br />
document.write(sTime);<br />
}<br />
<br />
<script>ConvertTime("<%=Now%>","03-25-2005 17:06")</script>
http://xwega.com/codeproject/timezone.asp[^]
|
|
|
|
|
The timezone is already inplace in the profile but updating the timestamp everywhere in the site where a time is displayed hasn't been done because there are other items I feel a more important.
It's far, far easier simply to calculate an offset based on the reader's timezone and the server's timezone and then do
DateTime RelativeDate = AbsoluteDate.AddHours(Offset);
return RelativeDate.ToShortTimeString();
cheers,
Chris Maunder
|
|
|
|
|
i started to make a script using timezons ,but a very big problem came up (lightsaving).
Chris Maunder wrote:
simply to calculate an offset based on the reader's
yes it is , but you can do it all on the client side, less for the servers to do.
and in case you did not take a look at my previus posts on this thread here it is:
and one optimization can be made:
istead of sending the servertime to the function everytime , you can declare it inside the fuction, avoiding to much calls to "Now" on the server.
function ConvertTime(svrdate,anydate)<br />
{<br />
clientDate = new Date();<br />
serverDate = new Date(svrdate);<br />
date = new Date(anydate);<br />
<br />
datediff = (clientDate.valueOf()-serverDate.valueOf())/1000/60;
date.setMinutes(date.getMinutes()+datediff);
<br />
h = date.getHours();<br />
n = date.getMinutes();<br />
sTime = h+":"+((n<10)?"0"+n:n)+" ";<br />
sDate = new String(date.toUTCString());<br />
sDate = sDate.substr(5,6); <br />
sDate+=" '"+(String(date.getFullYear()).substr(2,2));<br />
sTime+=sDate;<br />
document.write(sTime);<br />
}<br />
<br />
<script>ConvertTime("<%=Now%>","03-25-2005 17:06")</script>
it works:
http://xwega.com/codeproject/timezone.asp[^]
|
|
|
|
|
Why not displaying the server clock with javascript?
There could be multiple settings, e.g. a digital clock or analog clock.
Don't try it, just do it!
|
|
|
|
|
Heyas Chris and all the SiteBuilders,
Is there anyway to put the Currently Online count on the front page?
Just a thought
Thanks,
John
|
|
|
|
|
Open the forum and have a look at top right, then you will see it
Don't try it, just do it!
|
|
|
|
|
Okay CodeProject - I want:
coffee cups with the cool little alien guy (CLAG(tm)... gal? hard to
tell
I want some decent hats with the CLAG.
I want some t-shirts - quality t-shirts - with the CLAG and some
kind of catchy phrase. For example, I have a t-shirt from
Code Warrior - "Blood, Sweat, and Code."
Did I miss something on the web site?
C. Gilley
Will program for food...
Whoever said children were cheaper by the dozen... lied.
|
|
|
|
|
|
I *went* out to the store -didn't see it. Now I need a white cane with the WLAG....
thanks
C. Gilley
Will program for food...
Whoever said children were cheaper by the dozen... lied.
|
|
|
|
|
|
Oh, excuse me, he already has a name?
Who would have thought...
C. Gilley
Will program for food...
Whoever said children were cheaper by the dozen... lied.
|
|
|
|
|
|
CharlieG wrote:
CLAG(tm)
you mean Bob ?!
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Well, I have to say that it has been a long long time for me to experience slow webiste and very slow file download.
I was wondering IIS+ASP is just not good enough to handle the users of codeproject.com?
Regards,
unruledboy@hotmail.com
|
|
|
|
|
IIS+ASP is more then capable of running a site like this and more. ASP.Net is even more capable.
I can imagine the sinking feeling one would have after ordering my book,
only to find a laughably ridiculous theory with demented logic once the book arrives - Mark McCutcheon
|
|
|
|
|
..is it just me, or do others find tihs site painfully slow? It's a shame, because otherwise it's one of the best around... I am on a fast broadband connection but usually wait 15-20 seconds for a page to load - sometimes, they don't load at all and I am left looking at a blank screen. If I then hit the STOP button in my browser I will usually see half the page appear... I am using the latest IE6 on XP all up to date etc and have no problems on other sites...
cheers
Phil
|
|
|
|
|
It depends on the time of day, some blind luck, and the current phase of the moon.
Normally first thing in the morning (GMT) the site is nice and fast, slowing gradually over the day till sometimes it will be unbearably slow around 10pm. It should be noted though that in recent months the speed of the site has improved dramatically.
Die Freiheit spielt auf allen Geigen
|
|
|
|
|
CodeProject.com is becoming unusably slow on a more regular basis now. What the heck kind of server is the site running on? Is code optimization needed? Lets get this site fixed - its a great resource when it works!
|
|
|
|