JavaScript Unix Time

3 Years ago(Updated in 3 Years ago) JavaScript 0

"Unix time (a.k.a. POSIX time or Epoch time) is a system for describing instants in time, defined as the number of seconds that have elapsed since 00:00:00 Coordinated Universal Time (UTC), Thursday, 1 January 1970, not counting leap seconds. It is used widely in Unix-like and many other operating systems and file formats. Due to its handling of leap seconds, it is neither a linear representation of time nor a true representation of UTC. Unix time may be checked on most Unix systems by typing date +%s on the command line" Wikipedia.

JavaScript works with the number of milliseconds since the epoch whereas most other languages work with the seconds. You could work with milliseconds but as soon as you pass a value to say PHP, the PHP native functions will probably fail. So to be sure I always use the seconds, not milliseconds.

<script type="text/javascript">
function unixtime() {
   return Math.round(+new Date()/1000);


Recommended pages

Chart.js - Client side graphs for designers and developers...

Easy, object oriented client side graphs for designers and developers. "Chart.js" Address: Chart.js Features 6 Chart types HTML5 Based Simple and flexible ...


No comment here.
captcha image reload