PHP string in the format YYYY-DD-MM and a timestamp in MySQL

Mar 12, 2012   //   by   //   Blog, PHP Tutorial  //  No Comments

Doing comparisons between the date string and the MySQL timestamp.

You can avoid having to use strtotime() or getdate() in PHP buy using MySQL’s UNIX_TIMESTAMP() function.

SELECT UNIX_TIMESTAMP(timestamp) FROM sometable

The resulting data will be a standard integer Unix timestamp, so you can do a direct comparison to time().

Leave a comment

Share This Post

RSS Wordpress News