Skip to content

Instantly share code, notes, and snippets.

@davsclaus
Created April 26, 2013 12:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davsclaus/5467017 to your computer and use it in GitHub Desktop.
Save davsclaus/5467017 to your computer and use it in GitHub Desktop.
export function sinceFromTimestamp(timestamp) {
if (!timestamp) {
return null;
}
// convert from timestamp to delta since now
// 2013-04-26T145:01:17+0200
var time = Date.parse(timestamp);
var now = Date.now();
var diff = now - time;
return diff;
}
@davsclaus
Copy link
Author

Its in fact the values calculated it barfs about

@davsclaus
Copy link
Author

export function sinceFromTimestamp(timestamp: number) {
if (!timestamp) {
return null;
}

// convert from timestamp to delta since now
// 2013-04-26T145:01:17+0200
var time = new Date(timestamp);
var now = new Date();
var diff = now.getTime() - time.getTime();
return diff;

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment