Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible, or how to do it - to have bookmark (bookmarklet?) that, when clicking would open new page, that would have 2 parameters calculated based on current date?

For example, today it would open:

http://some.site/page?from=2011-11-01&to=2011-11-28

but in a week it would be

http://some.site/page?from=2011-12-01&to=2011-12-05
share|improve this question
    
Can't rattle off a specific solution off the top of my head, but yes, a JavaScript bookmarklet should be able to do this. – L2G Nov 28 '11 at 16:46
up vote 4 down vote accepted

Thanks for the opportunity to learn something! Here's what I came up with. Create a bookmark with the following in the Location field.

javascript:function z() { var d = new Date(); ym = d.getFullYear() + '-' + (d.getMonth()+1) + '-'; return 'http://some.site/page?from='+ym+'01&to='+ym+d.getDate(); } window.open(z(),"_blank");

It looks like you wanted from the first of the current month to the current date, correct?

share|improve this answer
    
Thanks - exactly what I was looking for. – user7385 Dec 1 '11 at 12:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.