converting date format from 0000-00-00 to timestamp
I have a date picker that returns date in the format 0000-00-00 with
$startT = isset($_POST["startT"]) ? $_POST["startT"] : "";
开发者_如何学运维
how do I convert this formatted date into a timestamp? Thanks
If you have PHP 5.3, which you should, the easiest way is:
$timestamp = new DateTime($_POST['startT']);
$timestamp->getTimestamp();
The easiest way is
echo mktime($_POST["startT"]);
Use strtotime() which works pretty fine in most cases
$time = strtotime($_POST['startT']);
精彩评论