In PHP we can manipulate dates using functions such as date , strtotime , mktime , and so on. and from version 5.3 of it we can manipulate dates in an object-oriented way with the DateTime , DateInterval , DatePeriod classes, and so on. >
Using functions:
<?php
date_default_timezone_set('America/Sao_Paulo');
echo date('d-m-Y H:i:s');
Using classes:
<?php
$timeZone = new DateTimeZone('America/Sao_Paulo');
$currentDateTime = new DateTime('now', $timeZone);
echo $currentDateTime->format('d-m-Y H:i:s');
What would be the most advisable and performative way to manipulate dates in PHP, using it in an object-oriented or structured way?