Use only the date part

In the following example only the date part is set. Time is set to by default to 00:00:00. So the following query compares all entries archived within a day (2021-06-14):

var start = new Date("2021-06-14");
var end = new Date("2021-06-15");

db.call_archive.find({archivedAt: {$gte: start, $lt: end}}).pretty();

Use both date and time

You can also specify the Time in ISO format

  • new Date("<YYYY-mm-ddTHH:MM:ss>") - specifies the datetime in the client’s local timezone and returns the ISODate with the specified datetime in UTC
  • new Date("<YYYY-mm-ddTHH:MM:ssZ>") - specifies the datetime in UTC and returns the ISODate with the specified datetime in UTC
var start = new Date("2021-06-14T13:13:13Z");
var end = new Date("2021-06-14T14:13:13Z");

db.call_archive.find({archivedAt: {$gte: start, $lt: end}}).sort({archivedAt: -1}).pretty(); //sort descending

Reference - https://docs.mongodb.com/manual/reference/method/Date/


Shared with from Codever.land. 👉 Use the Copy to mine functionality to copy this snippet to your own personal collection and easy manage your code snippets.

Use case

I find my self often use the autocomplete function of my last searches in the search box to find and access bookmarks and snippets I recently looked for. I figured out since I do that, why not make it easier. So I did - I added sort of quick access to my last searches directly from the side menu in the landing page. See it in action below:

Quick access to My Last Searches animation
Quick access to My Last Searches animation

One tricky part was to show the whole content of the search when its length passes a certain limit. That meant when hovering dynamically changing the content of the html anchor a element. This was even more difficult, because the list is dynamically generated out of the last searches. Let’s see how I implemented that.

Continue Reading ...

There are times when you need to set a css class of a html element dynamically in angular, given a simple or complex condition. This was the case for me when I had to set a different backround-color and color attributes for an anchor a html element to display the latest searches on the landing page of Codever

Continue Reading ...

Recently I wrote a few posts on my personal blog with lots of pictures. To save on bandwidth and load time it’s very important to reduce the size of the images. Which until recently I did manually in Preview, MacOS. It was a rather cumbersome manual process, that I automated with the help of Node.js/ExpressJS and Jimp In this post I will presently the implementation.

The code for this nad usage instructions are open source and available on Github

Continue Reading ...

You can now export your bookmarks and snippets from Bookmarks.dev for backup or other purposes. You can do that by going to your dashboard and click Export my bookmarks button. A dialog will pop up to ask whether you want to see your bookmarks or snippets in the browser(this opens a new window) or save them as a json file:

Export my snippets

Continue Reading ...