I have a file with the following lines. I want to identify rows that have timestamps in less than a week (starting from August 22 for this example).
log3.txt 28-08-2011 10:29:25 A string 29-08-2011 14:29:25 A new string 20-08-2011 14:29:25 Don't include php file if($file = fopen("/opt/apache2/htdocs/log3.txt", "r")) { while(!feof($file)) { $contents = fgets($file, 23);
date('mdY H:i:s') are created using date('mdY H:i:s') .
Why fgets requires 23 characters when it is actually 22.
What am I doing wrong here with strtotime?
What is the best way to parse lines with timestamps less than a week ago.
EDIT: Got his job
$date = DateTime::createFromFormat('dmY H:i:s', $contents); if(strtotime($date->format('dmY H:i:s')) > strtotime("last Monday"))
Use the DateTime function with the format dmY or m/d/Y
Thanks for helping all the guys.
source share