Gmail for yesterday’s jobs – a special redirect for searching gmail by date.

Hey, so the recent article I did on extending your gmail search was very well received, so here’s another tip (that I’ve slightly souped up) for this article  – I hope it useful for anyone who finds searching gmail by date a bit of a pain. 

I try and get everything in my inbox out and dealt with within 24 hours. But when I come online in the morning I get distracted by the stuff at the top of my inbox and forget, so things that come in at 10am often catch my eye more easily than the stuff that comes in at 6am.   

Writing a search for ‘inbox NOT including today’ is slightly counterintuitive and somewhat of a pain so I put together a custom redirect of my own that brings up the stuff from yesterday that I need to finish  If I got to 

http://joereddington.com/back/0 

That redirects a user to their inbox with a custom search string that searches gmail by date. The search shows only those emails that turned up before today. It’s parameterisable so 

http://joereddington.com/back/4  

takes you back four days and 

http://joereddington.com/back/10  

takes your back ten days (this has never been useful, I promise).  

The string is left in the search bar

Screen Shot 2014-07-30 at 18.39.21

so If you wanted to play with it, you can add extra terms and see where you end up.

It’s been useful for me so I thought I’d share to see if it was interesting for anyone else. 

Because it might help people make up their mind, or achieve something similar (or, more likely, point out were I went wrong)  here’s the relevant php (although I’ve also changed it in response to this) : 

<script type="text/javascript"><!--
var d = new Date()
var days=<?
$url = $_SERVER["REQUEST_URI"]; // gives /test/test/ from http://example.org/test/test/
echo substr("$url",6);
echo "\n";
?>-1

d.setTime(d.getTime()-86400*1000*days);
window.location = "https://mail.google.com/mail/?shva=1#search/in%3Ainbox+before%3A"+(d.getYear()+1900)+"%2F"+(d.getMonth()+1)+"%2F"+
d.getDate()
; //--> </script>

….and here’s the relevant bit of the .htaccess file that lets the nice url redirection work.  

RewriteEngineon

RewriteRule ^back/([0-9]+) redirect.php [PT]

One thought on “Gmail for yesterday’s jobs – a special redirect for searching gmail by date.

  1. rachelberensonperkins

    Tedx (aka Ted mini or Ted shuffle in ipod analogy) speech feels great. Looking forward to seeing it with the visual aids. Proud. 🙂

Leave a Reply