Date Counter Bookmarklet

Ever needed to calculate a date in the future but didn’t feel like looking it up? My girlfriend Katie was looking up dates for an invoice so I created a bookmarklet that takes a number of days and then alerts it to screen so you can copy and paste it. I might end up fixing it in the future so that it’ll print the result to whatever field is currently focused, but for now, you’ll all have to make due.

FutureDate

Here’s the source if anyone is interested:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
javascript:(
  function()
    {
    MoY = new Array();
    MoY[0]  = "January";
    MoY[1]  = "February";
    MoY[2]  = "March";
    MoY[3]  = "April";
    MoY[4]  = "May";
    MoY[5]  = "June";
    MoY[6]  = "July";
    MoY[7]  = "August";
    MoY[8]  = "September";
    MoY[9]  = "October";
    MoY[10] = "November";
    MoY[11] = "December";
 
    var theDays = prompt('How Many Days Until The Invoice Is Due?','');
 
    if(!isNaN(parseFloat(theDays)) && theDays!='')
      {
      d = new Date();
      t = d.getTime();
      n = new Date(t + theDays*24*60*60*1000);
      nty = n.getYear();
 
      if(nty < 1900)
        {
        nty = nty+1900;
        }
 
      nt  = MoY[n.getMonth()]+' '+n.getDate()+', '+nty;
      prompt('Copy and Paste This Date', nt);
      }
    }
)()

Let me know in the comments if you find this tool useful!

Tags: ,

No comments yet.

Leave a Reply