- Read the file, line by line (if it's large) or into an array, if small enough to handle in RAM.
- Test the data for your first condition.
- When found, test the same data for your second condition.
- If both are satisfied, write to new file, STDOUT or whatever
- Repeat until the date-time is greater than your second condition.
This is not a code writing service.
So, based on the sequence of hints above, read the docs, write some code, and come back with specific questions about specific functions or operations if you get stuck.