PHP MySQL - SQL Query on row with date (needs converting to Epoch time)


I am running a PHP MySQL SQL query on a table, one of the tables has a date column named 'date'.
Example data stored is '26/12/2015 12:00 PM'

I am wanting to run a query to ORDER the search results in most closest date first.  
If i store as Epoch time i can ORDER in ASC easily, but if i store as i have now it won't properly order.

How can tweak by SQL query to perform the required results?

$results = mysqli_query($link,"SELECT * FROM event ORDER BY date ASC") or die(mysql_error());

Open in new window

Hope someone can help?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

put backticks around your field names:

$results = mysqli_query($link,"SELECT * FROM `event` ORDER BY STR_TO_DATE(`date`,'%d/%m/%Y %h:%i %p') ASC") or die(mysql_error());

Open in new window

Refer to:

The format specifiers used by str_to_date() are the ones listed in date_format()

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
You would use the query changes hielo provided as input to the unix_timestamp(Str_to_date(hielo example))

You seem to have your date data stored as a string,
You might want to add a date time column, then run an update query that will use the information from one and store it as a datetime, or bigint() if you want the date stored as timestamp since epoch (1 jan 1970 00:00:00 GMt)
Ray PaseurCommented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.