領収証発行サービス
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

42 líneas
830B

  1. <?php
  2. namespace App\Util;
  3. use Illuminate\Support\Carbon;
  4. class DateUtil
  5. {
  6. public static function now()
  7. {
  8. if (!app()->environment('local')) {
  9. return new Carbon();
  10. }
  11. $nowStr = self::getConfig();
  12. if ($nowStr !== null && $nowStr !== '') {
  13. $date = new Carbon($nowStr);
  14. if ($date->isValid()) {
  15. return new Carbon();
  16. return $date;
  17. }
  18. }
  19. return new Carbon();
  20. }
  21. public static function parse(string $source): Carbon|null
  22. {
  23. $date = Carbon::parse($source);
  24. if ($date->isValid()) {
  25. return $date->timezone(config('app.timezone'));
  26. }
  27. return null;
  28. }
  29. private static function getConfig()
  30. {
  31. return config('date.now', null);
  32. }
  33. }