SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict
    Join Date
    Jan 2005
    Location
    Paris
    Posts
    370
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Mysql Stamp to JS?

    How do i change timestamp from a MYSQL database like this "1164279208" into a JS date 07-11-2007 ?
    On a PHP/Java/XML/Javascript/MySQL internship right now!

  2. #2
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Use FROM_UNIXTIME() in your MySQL query:
    Code sql:
    SELECT FROM_UNIXTIME(TIMESTAMP) TIMESTAMP FROM t1
    Saul

  3. #3
    SitePoint Addict
    Join Date
    Jan 2005
    Location
    Paris
    Posts
    370
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you one of my colleague is doing the php code that actually send those dates to the javascript object i am coding etc... i guess i have to tell him to kind of play with his code
    On a PHP/Java/XML/Javascript/MySQL internship right now!

  4. #4
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Did a quick lookup, you can do that in JS as well:
    Code JavaScript:
    var d = new Date();
    d.setTime(1164279208000);
    document.write(d);

    Note, that setTime() takes milliseconds as a parameter, so you've to multiply it by 1,000.

    Not sure what exactly the situation is, but converting it server-side is most likely a better option.
    Saul

  5. #5
    SitePoint Addict
    Join Date
    Jan 2005
    Location
    Paris
    Posts
    370
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes i did this


    Code:
    function dateTransform (smartlinkdate)
    {
    var ladate = new Date(smartlinkdate*1000);
    var lejour = ladate.getDay();
    var lemois = ladate.getMonth();
    var lannee = ladate.getFullYear();
    return (lejour + "-" + lemois + "-" + lannee);
    }
    On a PHP/Java/XML/Javascript/MySQL internship right now!


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
  •