Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. Site Bugs / Suggestions
  4. Time

Time

Scheduled Pinned Locked Moved Site Bugs / Suggestions
sysadmintools
15 Posts 7 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Max Santos
    wrote on last edited by
    #1

    it would be cool to gave the forum posts in our own time , and i think you can doit without any server intervention. you can provide a way to configure time zone in the profile , and then show the time acording using only client side script servers would not feel a thing

    P M C A 4 Replies Last reply
    0
    • M Max Santos

      it would be cool to gave the forum posts in our own time , and i think you can doit without any server intervention. you can provide a way to configure time zone in the profile , and then show the time acording using only client side script servers would not feel a thing

      P Offline
      P Offline
      PJ Arends
      wrote on last edited by
      #2

      Not to speak for Chris, but if you wrote and supplied the script to him I am sure it would get done faster. If you wait for Chris to write it he will just put it on his TODO list and we could be waiting awhile.


      "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

      M 1 Reply Last reply
      0
      • P PJ Arends

        Not to speak for Chris, but if you wrote and supplied the script to him I am sure it would get done faster. If you wait for Chris to write it he will just put it on his TODO list and we could be waiting awhile.


        "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

        M Offline
        M Offline
        Max Santos
        wrote on last edited by
        #3

        OK then... here it is: function ConvertTZ(msgDate) { date = new Date(msgDate); date.setHours(date.getHours()-serverTZ+userTZ); //the convertion d = date.getDate(); m = (date.getMonth()+1); h = date.getHours(); m = date.getMinutes(); sDate = ((h<10)?"0"+h:h)+":"+((m<10)?"0"+m:m)+" "+((d<10)?"0"+d:d)+"-"+((m<10)?"0"+m:m)+"-"+date.getFullYear(); document.write(sDate); } and this can be called like this ConvertTZ("<%=Now%>") it can be tested here : http://xwega.com/codeproject/timezone.asp[^] will Chris see this post? :-D

        D P 2 Replies Last reply
        0
        • M Max Santos

          OK then... here it is: function ConvertTZ(msgDate) { date = new Date(msgDate); date.setHours(date.getHours()-serverTZ+userTZ); //the convertion d = date.getDate(); m = (date.getMonth()+1); h = date.getHours(); m = date.getMinutes(); sDate = ((h<10)?"0"+h:h)+":"+((m<10)?"0"+m:m)+" "+((d<10)?"0"+d:d)+"-"+((m<10)?"0"+m:m)+"-"+date.getFullYear(); document.write(sDate); } and this can be called like this ConvertTZ("<%=Now%>") it can be tested here : http://xwega.com/codeproject/timezone.asp[^] will Chris see this post? :-D

          D Offline
          D Offline
          DavidNohejl
          wrote on last edited by
          #4

          It would be cool to somehow determine time zone from IP addres or browser settings... or something. Just a thought. David Never forget: "Stay kul and happy" (I.A.)
          David's thoughts / dnhsoftware.org / MyHTMLTidy

          1 Reply Last reply
          0
          • M Max Santos

            OK then... here it is: function ConvertTZ(msgDate) { date = new Date(msgDate); date.setHours(date.getHours()-serverTZ+userTZ); //the convertion d = date.getDate(); m = (date.getMonth()+1); h = date.getHours(); m = date.getMinutes(); sDate = ((h<10)?"0"+h:h)+":"+((m<10)?"0"+m:m)+" "+((d<10)?"0"+d:d)+"-"+((m<10)?"0"+m:m)+"-"+date.getFullYear(); document.write(sDate); } and this can be called like this ConvertTZ("<%=Now%>") it can be tested here : http://xwega.com/codeproject/timezone.asp[^] will Chris see this post? :-D

            P Offline
            P Offline
            PJ Arends
            wrote on last edited by
            #5

            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

            M 2 Replies Last reply
            0
            • P PJ Arends

              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

              M Offline
              M Offline
              Max Santos
              wrote on last edited by
              #6

              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?

              1 Reply Last reply
              0
              • P PJ Arends

                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

                M Offline
                M Offline
                Max Santos
                wrote on last edited by
                #7

                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) { clientDate = new Date(); serverDate = new Date(svrdate); date = new Date(anydate); datediff = (clientDate.valueOf()-serverDate.valueOf())/1000/60; //minutes date.setMinutes(date.getMinutes()+datediff); //the convertion h = date.getHours(); n = date.getMinutes(); sTime = h+":"+((n<10)?"0"+n:n)+" "; sDate = new String(date.toUTCString()); //because string allways have the same format i place hardcoded values instead of making a search sDate = sDate.substr(5,6); sDate+=" '"+(String(date.getFullYear()).substr(2,2)); sTime+=sDate; document.write(sTime); } ConvertTime("<%=Now%>","03-25-2005 17:06") http://xwega.com/codeproject/timezone.asp[^]

                P N 2 Replies Last reply
                0
                • M Max Santos

                  it would be cool to gave the forum posts in our own time , and i think you can doit without any server intervention. you can provide a way to configure time zone in the profile , and then show the time acording using only client side script servers would not feel a thing

                  M Offline
                  M Offline
                  Michael Dunn
                  wrote on last edited by
                  #8

                  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

                  M 1 Reply Last reply
                  0
                  • M Michael Dunn

                    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

                    M Offline
                    M Offline
                    Max Santos
                    wrote on last edited by
                    #9

                    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. function ConvertTime(svrdate,anydate) { clientDate = new Date(); serverDate = new Date(svrdate); date = new Date(anydate); datediff = (clientDate.valueOf()-serverDate.valueOf())/1000/60; //minutes date.setMinutes(date.getMinutes()+datediff); //the convertion d = date.getDate(); m = date.getMonth()+1; h = date.getHours(); n = date.getMinutes(); sTime = h+":"+((n<10)?"0"+n:n)+" "; sDate = new String(date.toUTCString()); //because string allways have the same format i place hardcoded values instead of making a search sDate = sDate.substr(5,6); sDate+=" '"+(String(date.getFullYear()).substr(2,2)); sTime+=sDate; document.write(sTime); } ConvertTime("<%=Now%>","03-25-2005 17:06") http://xwega.com/codeproject/timezone.asp[^]

                    1 Reply Last reply
                    0
                    • M Max Santos

                      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) { clientDate = new Date(); serverDate = new Date(svrdate); date = new Date(anydate); datediff = (clientDate.valueOf()-serverDate.valueOf())/1000/60; //minutes date.setMinutes(date.getMinutes()+datediff); //the convertion h = date.getHours(); n = date.getMinutes(); sTime = h+":"+((n<10)?"0"+n:n)+" "; sDate = new String(date.toUTCString()); //because string allways have the same format i place hardcoded values instead of making a search sDate = sDate.substr(5,6); sDate+=" '"+(String(date.getFullYear()).substr(2,2)); sTime+=sDate; document.write(sTime); } ConvertTime("<%=Now%>","03-25-2005 17:06") http://xwega.com/codeproject/timezone.asp[^]

                      P Offline
                      P Offline
                      PJ Arends
                      wrote on last edited by
                      #10

                      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

                      1 Reply Last reply
                      0
                      • M Max Santos

                        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) { clientDate = new Date(); serverDate = new Date(svrdate); date = new Date(anydate); datediff = (clientDate.valueOf()-serverDate.valueOf())/1000/60; //minutes date.setMinutes(date.getMinutes()+datediff); //the convertion h = date.getHours(); n = date.getMinutes(); sTime = h+":"+((n<10)?"0"+n:n)+" "; sDate = new String(date.toUTCString()); //because string allways have the same format i place hardcoded values instead of making a search sDate = sDate.substr(5,6); sDate+=" '"+(String(date.getFullYear()).substr(2,2)); sTime+=sDate; document.write(sTime); } ConvertTime("<%=Now%>","03-25-2005 17:06") http://xwega.com/codeproject/timezone.asp[^]

                        N Offline
                        N Offline
                        Nish Nishant
                        wrote on last edited by
                        #11

                        Wow, looks very good. I appreciate the effort you put into this :-) Nish

                        M 1 Reply Last reply
                        0
                        • N Nish Nishant

                          Wow, looks very good. I appreciate the effort you put into this :-) Nish

                          M Offline
                          M Offline
                          Max Santos
                          wrote on last edited by
                          #12

                          thank you. Very nice to ear it. Any chance this end up on the CodeProject boards some day? :-D

                          1 Reply Last reply
                          0
                          • M Max Santos

                            it would be cool to gave the forum posts in our own time , and i think you can doit without any server intervention. you can provide a way to configure time zone in the profile , and then show the time acording using only client side script servers would not feel a thing

                            C Offline
                            C Offline
                            Chris Maunder
                            wrote on last edited by
                            #13

                            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

                            M 1 Reply Last reply
                            0
                            • C Chris Maunder

                              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

                              M Offline
                              M Offline
                              Max Santos
                              wrote on last edited by
                              #14

                              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 :D 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) { clientDate = new Date(); serverDate = new Date(svrdate); date = new Date(anydate); datediff = (clientDate.valueOf()-serverDate.valueOf())/1000/60; //minutes date.setMinutes(date.getMinutes()+datediff); //the convertion h = date.getHours(); n = date.getMinutes(); sTime = h+":"+((n<10)?"0"+n:n)+" "; sDate = new String(date.toUTCString()); //because string allways have the same format i place hardcoded values instead of making a search sDate = sDate.substr(5,6); sDate+=" '"+(String(date.getFullYear()).substr(2,2)); sTime+=sDate; document.write(sTime); } ConvertTime("<%=Now%>","03-25-2005 17:06") it works: http://xwega.com/codeproject/timezone.asp[^]

                              1 Reply Last reply
                              0
                              • M Max Santos

                                it would be cool to gave the forum posts in our own time , and i think you can doit without any server intervention. you can provide a way to configure time zone in the profile , and then show the time acording using only client side script servers would not feel a thing

                                A Offline
                                A Offline
                                Alexander M
                                wrote on last edited by
                                #15

                                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! ;-)

                                1 Reply Last reply
                                0
                                Reply
                                • Reply as topic
                                Log in to reply
                                • Oldest to Newest
                                • Newest to Oldest
                                • Most Votes


                                • Login

                                • Don't have an account? Register

                                • Login or register to search.
                                • First post
                                  Last post
                                0
                                • Categories
                                • Recent
                                • Tags
                                • Popular
                                • World
                                • Users
                                • Groups