i'm trying to make a feature on my site that will search for news articles posted before/after/between different dates.
it occurs to me that i would have to let the user enter a date, and then somehow convert that date into a timestamp so it can be used in a mysql query.
i'm not really sure how to go about doing this. any suggestions?
first of all, which do you plan to use? mysql timestamps or unix timestamps?
You can make unix timestamps using mktime or strtotime
I usually use mktime, but strtotime is better if you want to directly pass the user input to this function to get the timestamp.
good luck! -sridhar
I suggest setting up a form that allows users to eneter dates in a specific format (via selects) and then use strtotime() and date() to format them for whatever mySQL time/date type you are using.
if you use selects to have the user specify the date, then mktime would be a faster way to construct the timestamp since you already have the month, date, and year in a variable:
$timestamp = mktime(0,0,0,$month,$date,$year);
-sridhar