10 examples of 'moment from now' in JavaScript

Every line of 'moment from now' 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
235public toFromNow(): string {
236 return moment.utc(this.value).fromNow();
237}
164public fromNow(date) {
165 return moment(date).fromNow();
166}
9getNow() {
10 return this.now;
11}
6function fromNow(value:Date): any {
7 if(value){
8 return moment(value).fromNow();
9 }
10}
3export function fromNow(startDate) {
4 if (typeof startDate === 'string') {
5 startDate = new Date(startDate);
6 }
7 const durationMillis = new Date().getTime() - startDate.getTime();
8 const duration = moment.duration(durationMillis);
9 if (duration.days() === 0) {
10 return 'today';
11 }
12 else if (duration.days() === 1) {
13 return 'yesterday';
14 }
15 else {
16 return moment(startDate).format('MM/DD/YY');
17 }
18}
20function now() {
21 return (new Date()).toISOString()
22}
23function utcNowMoment() {
24 return moment.utc();
25}
74get fromNow() {
75 return this.dateFrom(new Date());
76}
27function utcNowMoment() {
28 return exports.moment.utc();
29}
36function getNow () {
37 var d = new Date();
38 return JSON.parse(JSON.stringify(d).replace('Z', '000Z'));
39}

Related snippets