Last active
November 22, 2019 08:21
-
-
Save junibrosas/cb67c24791646e9c7203151347c72983 to your computer and use it in GitHub Desktop.
Anything momentJS
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
// a few seconds ago | |
moment.fn.fromNowOrNow = function (a) { | |
if (Math.abs(moment().diff(this)) < 25000) { // 25 seconds before or after now | |
return 'just now'; | |
} | |
return this.fromNow(a); | |
} | |
// check expiry | |
const isExpired = moment().isAfter(activity.endDate); | |
// Find upcoming documents between start date and end date | |
.find({ | |
$and: [ | |
{ startDate: { $lte: new Date() } }, | |
{ endDate: { $gte: new Date() } }, | |
] | |
}) | |
// formats | |
// 'MMMM Do YYYY' - January 26th 2018 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment