Horst Walter Horst Walter - 2 months ago 7
MySQL Question

Convert mysql DB timestamp to int time for PHP touch

I have a mysql timestamp which looks like this:

2016-08-31 21:54:33
. I need to use this timestamp in PHP touch:
bool touch ( string $filename [, int $time = time() [, int $atime ]] )


How can I best convert into the
int
value needed in
touch
?

Answer

In an object oriented syle:

$dateTime = new DateTime("2016-08-31 21:54:33");
echo $dateTime->getTimestamp();
Comments