Reputation: 455
I need to convert DD/MM/YYYY h:m
eg 21/12/2015 17:14 this date to timestamp format using php and store it in mysql.
I have tried strtotime()
and some other functions but it's not working. Can any one help me on this. I'm using datepicker to generate the value for date time
Upvotes: 1
Views: 9098
Reputation: 7896
you can use DateTime class:
$dateStr = '21/12/2015 17:14';
echo $timestamp = \DateTime::createFromFormat('d/m/Y H:i', $dateStr)->getTimestamp();
Upvotes: 1
Reputation: 543
Use following code to convert "DD/MM/YYYY h:m" into timestamp
$dateString = "21/12/2015 17:14";
$timestamp = strtotime(str_replace("/", "-", $dateString));
Upvotes: 2