Рейтинг: 0  
На голосовании
Предложил Пользователь 262839 24.08.2016 10:12:24

Use International PHP dates with intl in Date time function bitrix

The default clause uses clause of The Intl By the   Gregorian-in-in calendar   But the CAN of IT Also the use of the make OTHER calendars by Specifying a fifth parameter in the calls to IntlDateFormatterconstructor.  For So by the the default for LEO previous example Would the include a specification-in calendar like the the following.

$ DateTime = new DateTime ();
$ IntlDateFormatter = new IntlDateFormatter ( 'es_ES', IntlDateFormatter :: FULL, IntlDateFormatter :: FULL, 'Australia / Yancowinna', IntlDateFormatter :: GREGORIAN);
$ IntlDateFormatter- the echo> the format ($ a DateTime);  // Martes, 21 de julio de 2015, 11:12:43 pm (Hora estándar de central Australia) Should you wish to use another-in the CAN-in calendar of IT the BE the specified '' as with . with the part of the the locale of the the the following example with with in Decided I of of have to use the  Buddhist-in-in calendar . $ A = a DateTime a new a DateTime ();  


 https://en.wikipedia.org/wiki/Buddhist_calendar  


$ IntlDateFormatter = new IntlDateFormatter ( 'es_ES @ calendar = buddhist', IntlDateFormatter :: FULL, IntlDateFormatter :: FULL, 'Australia / Yancowinna', IntlDateFormatter :: TRADITIONAL);
$ IntlDateFormatter- the echo> the format ($ a DateTime);  // Martes, 21 de julio de 2558 the BE the, 11:16:08 pm (Hora estándar de central Australia) Notice The That of The I of the below of the below code have changed the the locale for the (first parameter) toes_ES = @ -in calendar and the buddhist-in calendar (fifth parameter) toIntlDateFormatter :: TRADITIONAL.





Of The of Calendars   the the ICU   Allows you to-the-play with the include:
  • Japanese ( ) @calendar=japanese
  • Buddhist (  )@calendar=buddhist
  • Chinese (  )@calendar=chinese
  • Persian (  )@calendar=persian
  • Indian (  )@calendar=indian
  • Islamic (  )@calendar=islamic
  • Hebrew (  )@calendar=hebrew
  • Coptic (  )@calendar=coptic
  • Ethiopic (  )@calendar=ethiopic
There you have for So IT;  localised time zone aware dates with the PHP on the multiple-in calendar types.  The If the Provided your application formats suit the then the this is a simple way to the ensure your date and time information is readable in Various locations and languages.

in
Рейтинг: 0  
Новая
Предложил Пользователь 262839 24.08.2016 09:53:09

Use International PHP dates with intl in Date time function bitrix

The default uses clause Intl By the  Gregorian-in calendar  But IT CAN Also the make use of OTHER calendars by Specifying a fifth parameter in the calls to IntlDateFormatterconstructor. So by default the previous example would include a calendar specification like the following.

$ DateTime = new DateTime ();
$ IntlDateFormatter = new IntlDateFormatter ( 'es_ES', IntlDateFormatter :: FULL, IntlDateFormatter :: FULL, 'Australia / Yancowinna', IntlDateFormatter :: GREGORIAN);
echo $ IntlDateFormatter-> format ($ DateTime ); // Martes, 21 de julio de 2015, 11:12:43 p.m. (Hora estándar de central Australia)


Should you wish to use another-in calendar IT CAN the BE specified 'as with the part of the locale. The the following example with In I of have Decided to use the  Buddhist-in calendar .

$ A DateTime = new a DateTime ();
$ IntlDateFormatter = new IntlDateFormatter ( 'es_ES @ calendar = buddhist', IntlDateFormatter :: FULL, IntlDateFormatter :: FULL, 'Australia / Yancowinna', IntlDateFormatter :: TRADITIONAL);
echo $ IntlDateFormatter-> format ($ DateTime ); // Martes, 21 de julio de 2558 the BE, 11:16:08 p.m. (Hora estándar de central Australia)


Notice The That I of the below code have changed the locale for the (first parameter) toes_ES = @-in calendar and the buddhist-in calendar (fifth parameter) toIntlDateFormatter :: TRADITIONAL.


Calendars of The  the ICU  Allows you to-play with the include:
  • Japanese ( @calendar=japanese)
  • Buddhist ( @calendar=buddhist)
  • Chinese ( @calendar=chinese)
  • Persian ( @calendar=persian)
  • Indian ( @calendar=indian)
  • Islamic ( @calendar=islamic)
  • Hebrew ( @calendar=hebrew)
  • Coptic ( @calendar=coptic)
  • Ethiopic ( @calendar=ethiopic)
So there you have it; localised time zone aware dates with PHP on multiple calendar types. If the provided formats suit your application then this is a simple way to ensure your date and time information is readable in various locations and languages.
Рейтинг: 16.1901  
Новая
Предложил Пользователь 185101 15.12.2015 21:02:28

Добавить методы в класс \Bitrix\Main\Type\Date

Добавьте несколько методов в класс \Bitrix\Main\Type\Date
А именно
DateTime::modify
public function modify($modify)
{
   return $this->value->modify($modify);
}


DateTime::Diff
DateTime::setDate
public function setDate ($year, $month, $day)
{
   return $this->value->setDate($year, $month, $day);
}
А то работать очень не удобно. Я, допустим, очень привык работать с классом \DateTime
А когда в нем не оказалось метода modify, я был разочарован.
Я понимаю что, можно использовать метод  Date::createFromPhp(), но это очень неудобно.
Рейтинг: 4.885  
Новая
Предложил Пользователь 21978 19.10.2014 03:51:53

Добавить метод modify() для класса DateTime в D7

Прошу добавить метод modify(), наследуемый от \DateTime в
\Bitrix\Main\Type\Date (\bitrix\modules\main\lib\type\date.php)