DateHelper.php 570 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Bear
  5. * Date: 2020/4/22
  6. * Time: 上午11:50
  7. */
  8. namespace app\main\helper;
  9. class DateHelper
  10. {
  11. public static function ios_8601()
  12. {
  13. $current = microtime(true);
  14. $micro = '';
  15. if (strstr($current, '.')) {
  16. list(, $micro) = explode('.', microtime(true));
  17. }
  18. if (strlen($micro) > 3) {
  19. $micro = substr($micro, 0, 3);
  20. } else {
  21. $micro = str_pad($micro, 3, '0');
  22. }
  23. return sprintf("%s.%sZ", date('Y-m-d\TH:i:s'), $micro);
  24. }
  25. }