Magento 2 get the current date & time in phtml file

For getting the current date and time. You can use the below code:

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$objDate = $objectManager->create('Magento\Framework\Stdlib\DateTime\DateTime');
$date = $objDate->gmtDate();

What are the differences between indexOf() and lastIndexOf()expoundsofttechsolutionget the current date & time in phtml file in magento2