SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2010
    Posts
    51
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    where does Date object gets its date

    Hi all, i was wondering if it is true that the Date object gets its date from the user's local time, if so, could the user "hack" the time by adjusting his local time?

  2. #2
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    9,036
    Mentioned
    152 Post(s)
    Tagged
    2 Thread(s)
    The time does indeed come from the users local system in the case of Javascript. So yes, if the user tampers with their local time, the time shown in javascript will be tampered as well.
    Rémon - Hosting Advisor

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy

  3. #3
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,684
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by ScallioXTX View Post
    The time does indeed come from the users local system in the case of Javascript. So yes, if the user tampers with their local time, the time shown in javascript will be tampered as well.
    Tampering is not the only problem. Dates and times can be off because a person doesn't syncronize their clock, or because they may not know enough about setting their computers timezone.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  4. #4
    SitePoint Addict svcghost's Avatar
    Join Date
    Oct 2010
    Posts
    288
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yup. Right from their computer's clocks. This is why it's important to validate with server-side script as well. Just in case a tricky rascal wants to try and trick the system somehow.

  5. #5
    SitePoint Enthusiast
    Join Date
    Aug 2010
    Posts
    51
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    so if i wish to display the date that is not dependent on the user's system's clock, what may be the most appropriate solution?

  6. #6
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    9,036
    Mentioned
    152 Post(s)
    Tagged
    2 Thread(s)
    Quote Originally Posted by Pacerier View Post
    so if i wish to display the date that is not dependent on the user's system's clock, what may be the most appropriate solution?
    Use some kind of server side scripting like ASP, PHP, Java, etc
    Rémon - Hosting Advisor

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy

  7. #7
    SitePoint Enthusiast
    Join Date
    Aug 2010
    Posts
    51
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok thanks for the help =)


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
  •