Re: [PHP] strtotime('yesterday')
Richard Lynch wrote: On Tue, May 24, 2005 7:24 am, Rahul S. Johari said: Im 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 BErase Successful!/BbrAll 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) doesnt work. If I put strtotime(-2 days) or strtotime(-7 days) or even strtotime(8:00am)... They all work accordingly. How come (yesterday) isnt working? It doesnt delete anything. [EMAIL PROTECTED] burhan $ php -r echo date('r',strtotime('-1 day')); Tue, 24 May 2005 09:00:35 +0300 [EMAIL PROTECTED] burhan $ date Wed May 25 09:02:10 AST 2005 :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] strtotime('yesterday')
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 BErase Successful!/BbrAll 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: [EMAIL PROTECTED] http://www.informed-sources.com
Re: [PHP] strtotime('yesterday')
On Tue, May 24, 2005 7:24 am, Rahul S. Johari said: 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 BErase Successful!/BbrAll 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. Maybe strtotime('-1 day') would work. [shrug] You could also use http://php.net/mktime mktime(date('m'), -1); //This should be 24 hours before 'now', I think... Or maybe mktime(date('m'), date('d) -1); Whichever it is, PHP's mktime does the right thing even if you use, like: mktime(6, 0); //This is really May 31st, not June 0. PHP knows. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php