Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 30-10-2009
Member
 
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.
Reply With Quote
  #2  
Old 30-10-2009
Member
 
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 );
Reply With Quote
  #3  
Old 30-10-2009
Member
 
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.
Reply With Quote
  #4  
Old 30-10-2009
Member
 
Join Date: May 2008
Posts: 2,293
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.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Javascript Unix Timestamp"
Thread Thread Starter Forum Replies Last Post
Problem in retrieving timestamp Logan 2 Software Development 5 12-02-2010 01:55 AM
What is Timestamp in SQL? Shekhar12 Software Development 4 30-11-2009 10:02 AM
C# timestamp datatype Mehraj Software Development 3 04-08-2009 06:58 PM
How to convert UNIX timestamp to MySQL Warner Software Development 2 16-05-2009 08:20 PM
Criteria with timestamp in MySQL Kirt Software Development 3 09-05-2009 12:09 PM


All times are GMT +5.5. The time now is 05:30 AM.