Created
April 26, 2013 12:14
-
-
Save davsclaus/5467017 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
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
Its in fact the values calculated it barfs about