my problem is when the time and date stored in database the result in database is 0000-00-00 00:00:00.000000. how do the results match with the current time and date???
for this i used following the code:
$dateandtime = $_SERVER['REQUEST_TIME'];
Use date()
as the function formats a local date and time, and returns the formatted date string. Example:-
$date = date('m/d/Y H:i:s ', time());
This prints date and time in 24 hour format. For 12 hour with am/pm use:-
$date = date('m/d/Y h:i:s A', time());
I hope it help's you
you try this code :
$now = DateTime::createFromFormat('U.u', microtime(true));
echo $now->format("m-d-Y H:i:s.u");
You can readily do this this with the input format U.u.
$now = DateTime::createFromFormat('U.u', microtime(true)); echo $now->format("m-d-Y H:i:s.u");
This produces the following output:
04-13-2015 05:56:22.082300 From the PHP manual page for date formats:
U = Seconds since the Unix Epoch, u = Microseconds
Microseconds (added in PHP 5.2.2). Note that date() will always generate 000000 since it takes an integer parameter, whereas DateTime::format() does support microseconds if DateTime was created with microseconds.
You're inserting the wrong format, it should be Y-m-d H:i:s
don't be fooled by the fact that the name is similar as "timestamp" in PHP is different to "timestamp" in MySQL.