Converting TIMESTAMP to unix time in PHP?
Currently I store the time in my database like so: 2010-05-17 19:13:37 However, I need to compare two times, and I feel it would be easier to do if it were a unix timestamp such as 1274119041 . (These two times are different) So how could I convert the timestamp to unix timestamp? Is there a simple php function for it? You're looking for strtotime() You want strtotime : print strtotime('2010-05-17 19:13:37'); // => 1274123617 Getting a unixtimestamp: $unixTimestamp = time(); Converting to mysql datetime format: $mysqlTimestamp = date("Y-m-d H:i:s", $unixTimestamp); Getting some mysql timestamp