Advertisement
Guest User

Untitled

a guest
Aug 30th, 2015
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. composer require nesbot/carbon
  2.  
  3. <?php
  4. require 'vendor/autoload.php';
  5. use CarbonCarbon;
  6. $data = new Carbon('2015-08-20', 'America/Sao_Paulo');
  7. $data->setLocale('pt_BR');
  8. echo $data->diffForHumans() .PHP_EOL;
  9.  
  10. $data->addDays(3);
  11. echo $data->diffForHumans() .PHP_EOL;
  12.  
  13. hรก 1 semana
  14. hรก 6 dias
  15.  
  16. composer require coduo/php-humanizer
  17.  
  18. <?php
  19. require 'vendor/autoload.php';
  20. use CoduoPHPHumanizerDateTime;
  21.  
  22. $data = new DateTime('2015-08-10');
  23. echo DateTime::difference($data, new DateTime()) .PHP_EOL;
  24. echo DateTime::preciseDifference($data, new DateTime()) .PHP_EOL;
  25.  
  26. 3 weeks from now
  27. 20 days, 18 minutes, 7 seconds from now
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement