tags:

views:

217

answers:

1

I'm trying to show only the emails received in the last 5 min for example

$since = date('d-M-Y G\:i', time() - 300); // current time - 5 min
$mb = imap_search ($m_mail, 'UNSEEN SINCE ' . $since . '');

Is there an easy way to do this ? I find a way: take all the unseen mails for the current day (ex:9 may 2010), loop it and then checking if it was send in the last X minutes echo it( using the imap_headerinfo->udate )BUT when i looked at gmail.com one email was recevied at 17:08 and on my server appears that the email was received at 14:08

UPDATE: i resolved the problem when it showed me that the email was sent at 17:04 in gmail.com and in my application showed me 14:04. I changed the global server timezone to GMT +0 and set the application timezone and now it show me the time correctly but still I don't know how to get the emails received in the last X in a shorter way.

A: 

As PHP uses IMAP2 search facilities which don't allow searching by time, this probably is the only solution. Or you could look at RECENT flag, but that still requires looping through all messages of the day.

andr