This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $dateTime = new DateTime('2016-12-01 00:00:01'); | |
| echo $dateTime->format('d/m/Y H:i:s') . PHP_EOL; | |
| //Subtraindo 3 anos e 2 meses de nossa data | |
| $dateTime->sub(new DateInterval('P3Y2M')); | |
| echo $dateTime->format('d/m/Y H:i:s'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $dateTime = new DateTime('2016-12-01 00:00:01'); | |
| echo $dateTime->format('d/m/Y H:i:s'), PHP_EOL; | |
| $dateTime->add(new DateInterval('P1YT10H55S')); | |
| echo $dateTime->format('d/m/Y H:i:s'), PHP_EOL; | |
| $dateTime->sub(new DateInterval('PT5H30M20S')); | |
| echo $dateTime->format('d/m/Y H:i:s'), PHP_EOL; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $dateTime = new DateTime('2016-12-01 00:00:01'); | |
| echo $dateTime->format('d/m/Y H:i:s'), PHP_EOL; | |
| //P1YT10H55S | |
| $dateTime->add(DateInterval::createFromDateString('1 year + 10 hours + 55 seconds')); | |
| echo $dateTime->format('d/m/Y H:i:s'), PHP_EOL; | |
| //PT5H30M20S |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $dateTime = new DateTime('2016-12-01 00:00:01'); | |
| echo $dateTime->format('d/m/Y H:i:s'), PHP_EOL; | |
| //Adiciondo dez dias a nossa data | |
| $dateTime->modify('10 days'); | |
| echo $dateTime->format('d/m/Y H:i:s'), PHP_EOL; | |
| //Subtraindo dez dias de nossa data |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $dateTime = new DateTime(); | |
| //Date | |
| $year = 2000; $month = 10; $day = 12; | |
| //Time | |
| $hour = 9; $minute = 1; $second = 10; | |
| $dateTime->setDate($year, $month, $day); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $myTimeZone = new DateTimeZone('America/Sao_Paulo'); | |
| $myDate = new DateTime('+2 months', $myTimeZone); | |
| echo $myDate->format('Y-m-d H:i:s A') . PHP_EOL; | |
| $myNewTimeZone = new DateTimeZone('Asia/Dubai'); | |
| $myDate->setTimezone($myNewTimeZone); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $dateTime1 = new DateTime('2016-12-01 12:10:15'); | |
| $dateTime2 = new DateTime('2018-01-08 08:18:09'); | |
| $interval = $dateTime1->diff($dateTime2); | |
| echo $interval->format('%y anos') . PHP_EOL; | |
| echo $interval->format('%m meses') . PHP_EOL; | |
| echo $interval->format('%d dias') . PHP_EOL; | |
| echo $interval->format('%h horas') . PHP_EOL; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!doctype html> | |
| <html> | |
| <head> | |
| <style type="text/css"> | |
| #app { | |
| width: 200px; | |
| padding: 20px; | |
| } | |
| #app .ctrl { | |
| height: 50px; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $myNumericArray = array( | |
| 100,// Tipo de dado numérico | |
| new DateTime(),// Tipo de dado Object | |
| 'String Any',// Tipo de dado String | |
| 89, | |
| 90 | |
| ); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $myNumericArray = array( | |
| 100,// Tipo de dado numérico | |
| new DateTime(),// Tipo de dado Object | |
| 'String Any',// Tipo de dado String | |
| 89, | |
| 90 | |
| ); |