|
- <?php
-
- namespace Lc\ShopBundle\Services ;
-
- class DateUtils
- {
- public function date($format, $timestamp)
- {
- setlocale(LC_TIME, 'fr_FR.UTF8', 'fr.UTF8', 'fr_FR.UTF-8', 'fr.UTF-8');
- return strftime($format, $timestamp) ;
- }
-
- public function getNextDay($day)
- {
- return new \DateTime('next '.$day) ;
- }
-
- public function getNextDayByNumber($number)
- {
- return $this->getNextDay($this->getDayByNumber($number, 'en')) ;
- }
-
- public function getDayByNumber($number, $lang = 'fr')
- {
- if($lang == 'fr') {
- $daysArray = [
- 1 => 'Lundi',
- 2 => 'Mardi',
- 3 => 'Mercredi',
- 4 => 'Jeudi',
- 5 => 'Vendredi',
- 6 => 'Samedi',
- 7 => 'Dimanche'
- ] ;
- }
- else {
- $daysArray = [
- 1 => 'Monday',
- 2 => 'Tuesday',
- 3 => 'Wednesday',
- 4 => 'Thursday',
- 5 => 'Friday',
- 6 => 'Saturday',
- 7 => 'Sunday',
- ] ;
- }
-
- if(isset($daysArray[$number])) {
- return $daysArray[$number] ;
- }
-
- return '' ;
- }
- }
|