1

I want to have a button where the user inputs the date In the format, e.g. 22 Dec 2010 07:55 AM. But it would be great if it was in the format just 22 Dec 2010 It should be converted to time in this format 1292984705 while trying to process it in a mysql query.

mysql_query("SELECT * FROM order_history where date>'$time1' AND date<'$time2' ORDER By id DESC");
0

1 Answer 1

3

Use the strtotime() function to convert the string representation of a date into a UNIX timestamp:

mysql_query("SELECT * FROM order_history where date > " . strtotime($time1) . " AND date < " . strtotime($time2) . " ORDER By id DESC");

Notice that I removed the quotes surrounding the concatenated timestamps, this will perform true arithmetic on the timestamps.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.