strtotime('yesterday')
| From: | Rahul S. Johari | Date: | Tue, 24 May 2005 14:24:14 +0000 |
| Subject: | strtotime('yesterday') | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-215796@lists.php.net to get a copy of this message | ||
Ave,
I¹m trying to delete all files in a folder based on a string match with the
following code:
<?
$dir = '/Library/WebServer/Documents/something.com/subfolder/';
$dp = opendir($dir) or die ('Fatal Error: '.mysql_error());
while ($file = readdir($dp)) {
if ((eregi('.png',$file)) && (filemtime($dir.$file)) <
(strtotime('yesterday'))) {
unlink($dir.$file);
}
}
closedir($dp);
$yesterday = mktime( 0, 0, 0, date("m") , date("d")-1, date("Y") );
$date = date( "m-d-y, D", $yesterday );
echo "<B>Erase Successful!</B><br>All images up to $date, have been
permanently erased from the Server.";
?>
I need the code to delete all images created till yesterday, and leave
images created today. Somehow strtotime(yesterday¹) doesn¹t work.
If I put strtotime(-2 days¹) or strtotime(-7 days¹) or even
strtotime(8:00am¹)... They all work accordingly. How come (yesterday¹)
isn¹t working? It doesn¹t delete anything.
Any tips?
Rahul S. Johari
Coordinator, Internet & Administration
Informed Marketing Services Inc.
251 River Street
Troy, NY 12180
Tel: (518) 266-0909 x154
Fax: (518) 266-0909
Email: rahul@informed-sources.com
http://www.informed-sources.com