You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

пре 3 година
пре 3 година
пре 3 година
пре 3 година
пре 3 година
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. namespace Lc\SovBundle\Component;
  3. class DateComponent
  4. {
  5. public function date($format, $timestamp)
  6. {
  7. setlocale(LC_TIME, 'fr_FR.UTF8', 'fr.UTF8', 'fr_FR.UTF-8', 'fr.UTF-8');
  8. return strftime($format, $timestamp);
  9. }
  10. public function getNextDay($day)
  11. {
  12. return new \DateTime('next ' . $day);
  13. }
  14. public function getNextDayByNumber($number)
  15. {
  16. return $this->getNextDay($this->getDayByNumber($number, 'en'));
  17. }
  18. public function getDayByNumber($number, $lang = 'fr')
  19. {
  20. if ($lang == 'fr') {
  21. $daysArray = [
  22. 1 => 'Lundi',
  23. 2 => 'Mardi',
  24. 3 => 'Mercredi',
  25. 4 => 'Jeudi',
  26. 5 => 'Vendredi',
  27. 6 => 'Samedi',
  28. 7 => 'Dimanche'
  29. ];
  30. } else {
  31. $daysArray = [
  32. 1 => 'Monday',
  33. 2 => 'Tuesday',
  34. 3 => 'Wednesday',
  35. 4 => 'Thursday',
  36. 5 => 'Friday',
  37. 6 => 'Saturday',
  38. 7 => 'Sunday',
  39. ];
  40. }
  41. if (isset($daysArray[$number])) {
  42. return $daysArray[$number];
  43. }
  44. return '';
  45. }
  46. // getDeliverySlotHour
  47. public function getHour(\DateTime $date)
  48. {
  49. $timestamp = $date->getTimestamp() ;
  50. $hour = $this->date('%kh', $timestamp) ;
  51. $minutes = $this->date('%M', $timestamp) ;
  52. if($minutes != '00') {
  53. $hour .= $minutes ;
  54. }
  55. return $hour ;
  56. }
  57. }