common.php 694 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * Desc: 公共方法
  5. * Author: Spt <2864934511@qq.com>
  6. * Date: 2024-03-13 15:11
  7. */
  8. if (!function_exists('datetime')) {
  9. /**
  10. * Generate the URL to a named route.
  11. *
  12. * @param null $time
  13. * @return string
  14. */
  15. function datetime($time = null): string
  16. {
  17. $time = $time ?: time();
  18. return date("Y-m-d H:i:s", (int)$time);
  19. }
  20. }
  21. if (!function_exists('getMillisecond')) {
  22. /**
  23. * Notes:获取毫秒
  24. * @return string
  25. */
  26. function getMillisecond(): string
  27. {
  28. list($s1, $s2) = explode(' ', microtime());
  29. return sprintf('%.0f', (floatval($s1) + floatval($s2)) * 1000);
  30. }
  31. }