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.
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.
Code for Javascript Unix Timestamp :
Code:var nDate = n Date( ); nDate.setTime( unixtime*1000 ); dateString = nDate.toUTCString );
To convert the current date and time to a UNIX timestamp in JavaScript follow the given example :
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.Code:var time = Mth.round(new Date().getTime() / 1000);
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.
Bookmarks