SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict tlacaelelrl's Avatar
    Join Date
    Apr 2011
    Location
    Mexico city, Mexico
    Posts
    353
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    date.parse returning wrong result

    Hello all,

    I may be doing this the wrong way but I been following the documentation to get the amount of seconds since epoch and I am getting the wrong result.

    Basically I have a string like this

    Code JavaScript:
    var myDateString='2013 02 06 13:05:00';

    or any other in same format so now I do this

    Code JavaScript:
    myDateString=Date.parse(myDateString);

    Which returns Wed Feb 06 2013 13:05:00 GMT+0100,

    Now, this thing I am running inside a jquery function which I am not sure if it is affecting it but I don't get why in the documentation says it will return the amount of seconds and it is returning a completely different thing.
    Do you get bothered because I do the same thing every day?
    Do you question why I do it?
    Then find something that you actually like doing!!!

    Stop thinking on what I do.

  2. #2
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,858
    Mentioned
    206 Post(s)
    Tagged
    12 Thread(s)
    Hi,

    It does return the number of milliseconds.
    If I do this:

    Code JavaScript:
    var myDateString='2013 02 06 13:05:00';
    myDateString=Date.parse(myDateString);
    console.log(myDateString);

    Then I see the output as: 1360152300000

    Maybe there is something else in your code that is affecting the result?


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
  •