Diferença entre Timestamp JavaScript

var a =  new Date();
var b = new Date(2013, 0, 1, 0, 0, 0, 0); // 01/01/2013
var diff = a - b;

var segundos = Math.round( diff / 1000 );
var minutos = Math.round( ( diff / 1000 ) / 60 );
var horas = Math.round( ( ( diff / 1000 ) / 60 ) / 60 );
var dias = Math.round( ( ( ( diff / 1000 ) / 60 ) / 60 ) / 24 );
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s