PageRenderTime 62ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/hphp/test/zend/good/ext/date/tests/strtotime-relative.php

http://github.com/facebook/hiphop-php
PHP | 47 lines | 35 code | 7 blank | 5 comment | 0 complexity | f679264a806e491105a6ac67c768a536 MD5 | raw file
Possible License(s): LGPL-2.1, BSD-2-Clause, BSD-3-Clause, MPL-2.0-no-copyleft-exception, MIT, LGPL-2.0, Apache-2.0
  1. <?hh
  2. <<__EntryPoint>> function main(): void {
  3. date_default_timezone_set('UTC');
  4. $base_time = 1204200000; // 28 Feb 2008 12:00:00
  5. $offsets = varray[
  6. // offset around a day
  7. '80412 seconds',
  8. '86399 seconds',
  9. '86400 seconds',
  10. '86401 seconds',
  11. '112913 seconds',
  12. // offset around 7 days
  13. '134 hours',
  14. '167 hours',
  15. '168 hours',
  16. '169 hours',
  17. '183 hours',
  18. // offset around 6 months
  19. '178 days',
  20. '179 days',
  21. '180 days',
  22. '183 days',
  23. '184 days',
  24. // offset around 10 years
  25. '115 months',
  26. '119 months',
  27. '120 months',
  28. '121 months',
  29. '128 months',
  30. // offset around 25 years (can't do much more reliably with strtotime)
  31. '24 years',
  32. '25 years',
  33. '26 years'
  34. ];
  35. foreach ($offsets as $offset) {
  36. foreach (varray['+', '-'] as $direction) {
  37. echo "$direction$offset: " . date(DATE_ISO8601, strtotime("$direction$offset", $base_time)) . "\n";
  38. }
  39. }
  40. }