How to format PHP date() for MySQL’s DateTime DataType

March 11, 2010 by paulhenry
Filed under: PHP Tutorials, Tutorials 

This is a simple call to a function like so:

Get the current time:
$time = date("y-m-d H\:i\:s");

Or get the current time from a timestamp, set to one week from the current time:
$nextWeek = time() + (7 * 24 * 60 * 60);
$time = date("y-m-d H\:i\:s", $nextWeek);

Comments

Comments are closed.