0
In PHP we can manipulate dates using functions such as date, strtotime, mktime etc. and from version 5.3 of it we can manipulate dates object-oriented with the classes Datetime, Dateinterval, Dateperiod and etc.
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 recommendable and performative way to manipulate dates in PHP, using them in an object-oriented or structured way?