SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict chartahir's Avatar
    Join Date
    Oct 2006
    Location
    Karachi, Pakistan
    Posts
    253
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Time Calculation Problem

    I want to get the time of the client city or country when the user hit my site, i can the user ip and then using it extract the country and for some ip the city name.

    How can i get the time of the user city or country ?

    I've tried some JS but they work on selecting manually the localtime(base) and then select the location for which i want to find the time, i tried to change but it didn't fit my requirement.

    Help plz ASAP.
    chartahir

  2. #2
    Caveat surfer Buddy Bradley's Avatar
    Join Date
    May 2003
    Location
    Cambridge, UK
    Posts
    2,366
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Won't using new Date() get the system time of the user's PC (which one would assume is the time in their city/country)? I would have thought you only need to worry about localization when using your own server time - the JS time should be correct.

  3. #3
    SitePoint Addict chartahir's Avatar
    Join Date
    Oct 2006
    Location
    Karachi, Pakistan
    Posts
    253
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i can get the server time to localize, but if i get the clients system time , it might not be correct thats why i want to find the time of the client using city or country,
    Is there any way i can do it easily or have to calculate it using the GMT (that some codes do) ???
    chartahir

  4. #4
    SitePoint Guru
    Join Date
    Apr 2006
    Posts
    802
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    var D=new Date().getTimeZoneOffset() returns the integer number of minutes between GMT and the local user's time. It accounts for daylight savings when appropriate. You would need a database of every city on earth to do it by city- and how did you get the city?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •