5 examples of 'angularjs timestamp' in JavaScript

Every line of 'angularjs timestamp' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
18public get timestamp() {
19 return this.timestampValue;
20}
86$scope.formatTimestamp = function formatTimestamp(timestamp) {
87 var totalSeconds = timestamp / 1000;
88 var minutes = Math.floor(totalSeconds / 60);
89 var seconds = Math.floor(totalSeconds % 60);
90 seconds = (seconds < 10 ? '0' : '') + seconds;
91 return minutes + ':' + seconds;
92};
6function TimestampController($scope, time) {
7 // A fuzzy, relative (eg. '6 days ago') format of the timestamp.
8 this.relativeTimestamp = null;
9
10 // A formatted version of the timestamp (eg. 'Tue 22nd Dec 2015, 16:00')
11 this.absoluteTimestamp = '';
12
13 let cancelTimestampRefresh;
14 const self = this;
15
16 function updateTimestamp() {
17 self.relativeTimestamp = time.toFuzzyString(self.timestamp);
18 self.absoluteTimestamp = dateUtil.format(new Date(self.timestamp));
19
20 if (self.timestamp) {
21 if (cancelTimestampRefresh) {
22 cancelTimestampRefresh();
23 }
24 cancelTimestampRefresh = time.decayingInterval(
25 self.timestamp,
26 function() {
27 updateTimestamp();
28 $scope.$digest();
29 }
30 );
31 }
32 }
33
34 this.$onChanges = function(changes) {
35 if (changes.timestamp) {
36 updateTimestamp();
37 }
38 };
39
40 this.$onDestroy = function() {
41 if (cancelTimestampRefresh) {
42 cancelTimestampRefresh();
43 }
44 };
45}
3export function timestampToDate(timestamp?: pb.google.protobuf.ITimestamp) {
4 let millis: number
5 if (!timestamp) {
6 millis = 0
7 } else {
8 millis = timestamp.seconds as number * 1e3 + timestamp.nanos / 1e6
9 }
10 return new Date(millis)
11}
73function timestamp() {
74 return dateformat('yyyy-mm-dd HH:MM:ss (Z)')
75}

Related snippets