Reputation: 597
Is this the correct way to get the current time in PHP using DateTime?
$currenttime = new DateTime();
$currenttime2 = $currenttime->format('H:i:s');
Upvotes: 0
Views: 148
Reputation: 1683
This will set the time based on your date time settings in php.ini. Do a var_dump of $currenttime after creation to see what I mean. You may also use microtime(true); to obtain a unix timestamp, which can be converted using other functions.
Upvotes: 0