如何在PHP中将字符串转换为日期/时间戳[重复]

This question already has an answer here:

I have a string which has the value '2015-06-04 00:00:00'

How can I convert this to a date/time stamp using PHP?

Many thanks,

Alec

</div>

Try this code

$time = strtotime('2015-06-04 00:00:00'); // convert to datetime
$date = date('Y-m-d H:i:s',$time);        // change format

got your answer you can convert it by use this

$date = strtotime('2015-06-04 00:00:00');
echo $date;

I always prefer to pass from a DateTime class.

php > $dateTime = new DateTime('2015-06-04 00:00:00');
php > echo $dateTime->format('d/m/Y');
04/06/2015