Drupal – Add a datestamp to your custom modules

I have several custom Drupal modules and when ever I make revisions & create a new version I update the datestamp.
Here’s a bookmarklet I use in Firefox to generate a datestamp.
Datestamp.
Just drag that to your bookmark bar and you’re good to go.

Here are my steps to use it:

  1. Click Datestamp bookmarklet;
  2. Select all;
  3. Copy;
  4. and then paste into your custom_module.info file:
    datestamp = "1354564856"

Here’s the code:

javascript:
(function(){
  var timeStamp=Math.round(((new Date()).getTime()-Date.UTC(1970,0,1))/1000);
  if(window.clipboardData){
    window.clipboardData.setData('Text',timeStamp);
  }
  else{
    wnd=open('','Datestamp for Drupal module .info files','width=500,height=100,top=0,left=0,scrollbars,resizable');
    with(wnd.document){
      writeln('<html><body><pre>');
      writeln(timeStamp);
      writeln('</pre></body></html>');
    }
    wnd.document.close();
  }
}
)();

It’s a simple bookmarklet;
It creates the datestamp in the correct format based on the current time:

Math.round(((new Date()).getTime()-Date.UTC(1970,0,1))/1000);

Then it either pushed that timestamp to your clipboard (if possible) or opens a new window with the timestamp inside it.

Here’s minified code in the link:

<a href="javascript:(function(){var%20timeStamp=Math.round(((new%20Date()).getTime()-Date.UTC(1970,0,1))/1000);if(window.clipboardData){window.clipboardData.setData('Text',timeStamp);}else{wnd=open('','Shell_Command','width=500,height=100,top=0,left=0,scrollbars,resizable');with(wnd.document){writeln('<html><body><pre>');writeln(timeStamp);writeln('</pre></body></html>');}wnd.document.close();}})();">Datestamp</a>
Comments
Leave a Comment