Results 1 to 4 of 4

Thread: Javascript Unix Timestamp

  1. #1
    Join Date
    Apr 2009
    Posts
    87

    Javascript Unix Timestamp

    I need code to for Unix timestamp in Javascript language. I tried to create a time object and function which works with time and date but program won't convert this to a UNIX timestamp.

  2. #2
    Join Date
    Jan 2009
    Posts
    199

    Re: Javascript Unix Timestamp

    Code for Javascript Unix Timestamp :
    Code:
    var nDate = n Date( );
    nDate.setTime( unixtime*1000 );
    dateString = nDate.toUTCString );

  3. #3
    Join Date
    Dec 2008
    Posts
    177

    Re: Javascript Unix Timestamp

    To convert the current date and time to a UNIX timestamp in JavaScript follow the given example :

    Code:
    var time = Mth.round(new Date().getTime() / 1000);
    getTime() function returns a value in milliseconds from the UNIX epoch and it is divided by 1000 to get the seconds representation. It is rounded using Mth.round() to make it a whole number.

  4. #4
    Join Date
    May 2008
    Posts
    2,297

    Re: Javascript Unix Timestamp

    try this for Javascript Unix Timestamp :
    Code:
    b = new Date()
    var e = Number(Date.UTC(b.getFullYear(),b.getMonth(),b.getDate(),b.getHours(),b.getMinut
    es(),b.getSeconds(),0));
    e = e/1000;
    // e would be the Unix timestamp for this moment.

Similar Threads

  1. Problem in retrieving timestamp
    By Logan 2 in forum Software Development
    Replies: 5
    Last Post: 12-02-2010, 01:55 AM
  2. What is Timestamp in SQL?
    By Shekhar12 in forum Software Development
    Replies: 4
    Last Post: 30-11-2009, 10:02 AM
  3. C# timestamp datatype
    By Mehraj in forum Software Development
    Replies: 3
    Last Post: 04-08-2009, 06:58 PM
  4. How to convert UNIX timestamp to MySQL
    By Warner in forum Software Development
    Replies: 2
    Last Post: 16-05-2009, 08:20 PM
  5. Criteria with timestamp in MySQL
    By Kirt in forum Software Development
    Replies: 3
    Last Post: 09-05-2009, 12:09 PM

Tags for this Thread

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
  •  
Page generated in 1,713,928,204.18226 seconds with 17 queries