No need to convert to timestamp for comparison, given that the strings are checked as dates in the canonical format "YYYY-MM-DD".
This test will work:
( ( $date_from_user >= $start_date ) && ( $date_from_user <= $end_date ) )
Given:
$start_date = '2009-06-17'; $end_date = '2009-09-05'; $date_from_user = '2009-08-28';
NOTE. Comparing strings like this allows for "invalid" dates, for example. (December 32) "2009-13-32" and for strangely formatted strings "2009/3/3", so string comparisons will NOT be equivalent to date or time comparisons. This works ONLY if the date values in the strings are in the CONSISTENT and CANONICAL format .
EDIT to add a note here stating the obvious.
By CONSISTENT, I mean, for example, that the lines to be compared must be in the same format: the month should always be two characters, the day should always be two characters, and the separator character should always be dashes. We cannot reliably compare “strings” that are not a four-year character, a two-character month, two characters. If we had a combination of one character and two-digit months in lines, for example, we would get an unexpected result when comparing, '2009-9-30' - '2009-10-11' . We humanly see that "9" is less than "10", but string comparisons will be '2009-9' more than '2009-1' . We do not have to have dash separator characters; we could reliably compare strings in the format 'YYYYMMDD' ; if there is a separation character, it must always be there and always be the same.
By CANONICAL , I mean a format that will result in strings that will be sorted in date order. That is, the line will have the representation of “year” first, then “month”, then “day”. We cannot reliably compare strings in the 'MM-DD-YYYY' format because this is not canonical. String comparison would compare MM (month) before it compared YYYY (year), since string comparison works from left to right.) The big advantage of the "YYYY-MM-DD" string format is that it is canonical; dates presented in this format can be reliably compared as strings.
[ADDITION]
If you want to convert php timestamp, keep in mind the limitations.
On some platforms, php does not support timestamp values earlier than 1970-01-01 and / or later than 2038-01-19. (What is the character unix timestamp 32-bit integer.) Later versions of pf php (5.3?) Should address this.
The time zone can also be a problem if you are not careful to use the same time zone when converting from a string to a time stamp and from a time stamp to a string.
NTN